Std.Json
SyntaxError
Section titled “SyntaxError”error SyntaxError(message: String, offset: Int)offset counts code points from the start of the input.
message: Stringoffset: Int
fn parse(s: String) -> Dynamic fails SyntaxErrorReads one JSON value, with whitespace allowed around it. For a repeated key in an object, the later value is kept.
to_string
Section titled “to_string”fn to_string(value: Dynamic) -> StringThe JSON text of value, without whitespace. Keys come in the order of the Map. A string
escapes ", \ and the control characters, and keeps every other character as it is. JSON has
no bytes, so Binary is written as a string of Bytes.to_base64 (RFC 4648 section 4). parse
never gives Binary: that string is read back as Text, and Bytes.from_base64 turns it into the
bytes.
decode
Section titled “decode”fn decode[A: Decode](text: String) -> A fails DecodeError | SyntaxErrorparse, then Decode.from_dynamic.
decode_all
Section titled “decode_all”fn decode_all[A: Decode](text: String) -> A fails DecodeErrors | SyntaxErrorparse, then Decode.from_dynamic_all.
encode
Section titled “encode”fn encode[A: Encode](value: A) -> StringEncode.to_dynamic, then to_string.