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.
Functions
Section titled “Functions”parse : String -> Result (Json, String)
Section titled “parse : String -> Result (Json, String)”Parse one JSON value. Trailing non-whitespace is an error.
parse "{\"id\":1}" # => Ok (JsonObject [("id", JsonInt 1)])stringify : Json -> String
Section titled “stringify : Json -> String”Compact JSON text for j.
stringify (JsonInt 1) # => "1"get : Json -> String -> Option Json
Section titled “get : Json -> String -> Option Json”Look up key in a JSON object. None if j is not an object or the key is missing.
asString : Json -> Option String
Section titled “asString : Json -> Option String”Unwrap a JSON string.
asInt : Json -> Option Int
Section titled “asInt : Json -> Option Int”Unwrap a JSON integer.