-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[doc] Update the readme with information for renaming field keys
- Loading branch information
Showing
5 changed files
with
115 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,3 @@ | |
# frontend code | ||
node_modules/ | ||
dist/ | ||
|
||
# | ||
more-details.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
import CandidTypes "Candid/Types"; | ||
|
||
import UrlEncodedModule "UrlEncoded"; | ||
import JsonModule "JSON"; | ||
import CandidModule "Candid"; | ||
|
||
module { | ||
|
||
public type Options = CandidTypes.Options; | ||
|
||
public type Candid = CandidTypes.Candid; | ||
|
||
public let Candid = CandidModule; | ||
public let JSON = JsonModule; | ||
public let URLEncoded = UrlEncodedModule; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
## Usage Examples | ||
|
||
### Candid Text | ||
```motoko | ||
import { Candid } "mo:serde"; | ||
type User = { | ||
name: Text; | ||
id: Nat; | ||
}; | ||
let blob = serdeCandid.fromText("(record({ name = \"bar\"; id = 112 }))", null); | ||
let user : ?User = from_candid(blob); | ||
assert user == ?{ name = "bar"; id = 112 }; | ||
``` | ||
|
||
### URL-Encoded Pairs | ||
Serialization and deserialization for `application/x-www-form-urlencoded`. | ||
|
||
This implementation supports URL query strings and URL-encoded pairs, including arrays and nested objects, using the format `items[0]=value&items[1]=value` and `items[subKey]=value`." | ||
|
||
```motoko | ||
import { URLEncoded } "mo:serde"; | ||
type User = { | ||
name: Text; | ||
id: Nat; | ||
}; | ||
let payload = "users[0][id]=123&users[0][name]=John&users[1][id]=456&users[1][name]=Jane"; | ||
let blob = URLEncoded.fromText(payload, null); | ||
let res : ?{ users: [User]} = from_candid(blob); | ||
assert res == ?{ users = [ | ||
{ | ||
name = "John"; | ||
id = 123; | ||
}, | ||
{ | ||
name = "Jane"; | ||
id = 456; | ||
}, | ||
] }; | ||
``` |