std/json
JSON as a format, written in TorbScript: an Encoder that writes the text, a parser into an EncodedValue that the
shared ValueDecoder of std/encoding reads a typed value out of, and JsonValue for a document whose shape is not
known ahead of time.
const json = Json()
const text = json.encode user
const back = json.decode<User>(text)?
Json is a value with the options of the format - how field names are spelled, and whether a field nobody read is an
error - so a convention of the format is never a property of a type. Json is also a Format<JsonError>, which is
what makes it work on a stream: Json.items<User>() is a Stage that turns byte chunks into Users one at a time.
Modules
std/json/libJSON as a format, written in TorbScript: anEncoderthat writes the text, a parser into anEncodedValuethat the sharedValueDecoderofstd/encodingreads a typed value out of, and [JsonValue] for a document whose shape is not known ahead of time.
Everything
- type
JsonJSON, with its options. - extend
Json with Format<JsonError>Everything a stream needs: a framer that finds where one element ends, and the ordinaryDecodefor the element itself. - type
JsonErrorWhat went wrong turning text into a value: malformed JSON, or JSON that parsed fine but does not fit the requested type. - extend
JsonError with From<Utf8Error>Whatchecked()needs to lift a broken byte sequence into the failure of a JSON stream. - type
JsonValueA JSON document without a fixed shape: config previews, diffing, passing on fields nobody has a type for yet. - extend
JsonValue with EncodeAJsonValuewrites itself into anyEncoder, not onlyJson's own.