Skip to main content

Module json

Module json 

Source
Expand description

json parse and stringify over the runtime Data graph.

Parsing maps a json document straight onto values candela already has: an object becomes a map keyed by strings, an array becomes an array, and a scalar becomes int/float/string/bool/null. No new runtime type is needed.

Parsed values allocate the way the program’s own do, reusing freed slots, so a parse can start or carry on a collection. The value is built top-down to stay reachable while it does: the outermost list or map sits on the recursion stack, a collection root, until the parse ends, and each entry goes into its parent before anything inside it is allocated. A string is interned, since a map finds a string key by its slot.

Functions§

json_parse
Parses a json document into a Data graph. A malformed document returns a short static reason.
json_stringify
Serializes a Data value to a json string.