keen/json

Source
This is a standard module and does not need to be explicitly imported.
json union
null record (has private fields)
json-object record -new
keys symbol[]
values json[]
You'll rarely need to use this directly since json can be constructed directly using named-new
to-json[t] spec
to json(a t)
from-json[t] spec
to t(a json)
is-empty bool(a json-object)
size nat64(a json-object)
some bool(a json-object, f bool mut((symbol, json)))
list-new json-object(pairs (symbol, json)[])
subscript json option(a json-object, key symbol)
interpolate json(parts string[])
deserialize-error record case
expected string
value json
show string(a deserialize-error)
list-new json(args json[])
If no arguments are passed this is null. Otherwise it is a JSON array. For an empty array, use empty-array or ()::json[]
named-new json(keys symbol[], values json[])
empty-array json[]()
empty-object json-object()
subscript json(a json, key symbol)

If a is an object containing the key key, returns the associated value. Returns null if any of these is true: * a is not an object. * a is an object, but does not have key. * a is an object with the key, and its value is null.

Most code does not care about this distinction. If you do, you can test if json-object a or if has-key a, key.

has-key bool(a json, key symbol)
true if a is an object and key is one of its keys.
show string(a json)
By default, json is shown using Kid syntax.
to-json[t] string(a t) t to-json
Converts a value to json and renders it as standard JSON.
omit-null-values json(a json)
omit-empty-values json(a json)
deep-omit-empty-values json(a json)
For every object in the json value, omit a key if the value is null, an empty array, or an empty object.
to-kid[t] string(a t) t to-json
Converts a value to json and renders it as Kid.