Skip to content

Std\Json

Recursive JSON values — object/array parse and stringify.

parse returns Result Json String. stringify emits compact JSON. get / asString / asInt work from expression programs (imported constructors can be pattern-matched). Scalar helpers (stringifyString, parseInt, …) stay available for fragments. yls-yona uses parse / stringify / get for JSON-RPC bodies.

Parse and stringify run in the C runtime (recursive ADT walk).

type Json =

JSON value: null, bool, int, float, string, array, or object. Objects preserve member order as a sequence of (key, value) pairs.

Parse one JSON value. Trailing non-whitespace is an error.

parse "{\"id\":1}" # => Ok (JsonObject [("id", JsonInt 1)])

Compact JSON text for j.

stringify (JsonInt 1) # => "1"

Look up key in a JSON object. None if j is not an object or the key is missing.

Unwrap a JSON string.

Unwrap a JSON integer.