crow/json.crow (source)

json union

JSON data.

== bool(a json, b json)

new json(...pairs (symbol, json) tuple2 array)

to json(a json)

to json(a bool)

to json(a char8)

to json(a char32)

to json(a nat8)

to json(a nat16)

to json(a nat32)

to json(a nat64)

to json(a int8)

to json(a int16)

to json(a int32)

to json(a int64)

to json(a float32)

to json(a float64)

to json(a string)

to json(a symbol)

to[t] json(a t array) (json, t) to

to[t] json(a t mut[]) (json, t) to

to[k, v] json(a k[v]) k key, (symbol, k) to, (json, v) to

to[t] json(a t?) (json, t) to

to[t, u] json(a (t, u) tuple2) (json, t) to, (json, u) to

to[t, u] json(a (t, u) result) (json, t) to, (json, u) to

symbol symbol?(a json)

subscript json(a json, key symbol)

If a is an object containing the key key, returns the associated value.
Returns null if:
* 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 obj ?= a object and if value ?= object[key].

bool-or-null bool?(a json)

x.bool-or-null is like x.bool, but treats null as false.

list-or-null json array?(a json)

x.list-or-null is like x.list, but treats null as an empty list.

json json grammar()

to[t] t array(a json) (t, json) to

to nat64(a json) bare

show string(a json)

Renders a json value to JSON.

to js-any(a json)

Converts from a json value to the corresponding JS object

to json(a js-any) unsafe

This does not fail on bad JS values, it just returns 'null'.