Reference

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

Everything