json
JSON serialization and deserialization.
Functions
encode value
Serializes a Do value to a JSON string.
Parameters
| Name | Type | Description |
|---|---|---|
value |
the value to serialize |
Returns
Str -- JSON string
Type mapping:
| Do Type | JSON Type |
|---|---|
nil |
null |
Bool |
boolean |
Int |
number |
Float |
number |
Str |
string |
Sym |
string (symbol name) |
array |
array |
dict |
object |
decode json
Deserializes a JSON string to a Do value.
Parameters
| Name | Type | Description |
|---|---|---|
json |
Str |
JSON string to parse |
Returns
The parsed Do value.
Errors
| Exception | Condition |
|---|---|
ValueError |
The JSON is invalid |
Type mapping:
| JSON Type | Do Type |
|---|---|
null |
nil |
| boolean | Bool |
| integer | Int |
| float | Float |
| string | Str |
| array | array |
| object | dict |