@json
Import this module with import @json.
| Function | Signature | Description |
|---|---|---|
decode |
(text string) -> (map[string:string], Error) |
Decode JSON string to map — always use destructuring |
parse |
(text string) -> T |
Parse JSON into a #json struct (context-dependent) |
encode |
(value T) -> string |
Encode to JSON string. Accepts any primitive (integers, f32/f64, char, bool, string), a flat array of primitives, or a string-keyed map of primitives. char encodes as its codepoint number. For #json structs use stringify. |
stringify |
(value T) -> string |
Encode a #json struct to a JSON string |
pretty_print |
(m map[K:V], indent i64) -> string |
Pretty-print a map as indented JSON |
is_valid |
(text string) -> bool |
Check if valid JSON |
decode is fallible: single-variable assignment is a compile-time error (E3089); the result must be destructured (mut m, err = ... or mut m, _ = ...).