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.std/json/pointerJsonPointer(RFC 6901): the address of one value inside a JSON document, as a typed value, andJsonValue.get, which follows it.
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
JsonPointerThe address of one value in a JSON document: a list of reference tokens, each the name of a member or the index of an array item, read from left to right. - type
JsonPointerErrorWhat went wrong reading a pointer or following it through a document: the pointer's text, the kind and the detail. - type
JsonPointerProblemWhy a [JsonPointerError] was raised. - 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. - extend
JsonValueAddsgetto a document, to read the value a pointer names.