Skip to main content

Module json

Module json 

Source
Expand description

Minimal JSON reader (doc 19, section 18.5).

Walks the text without building a tree: it can skip any value, hands out an object’s fields as name → text-span pairs and decodes a JSON string. A message’s body is any JSON, so the connector returns the text span without interpreting it.

Structs§

Fields
The fields of an object, searchable by name.
JsonError

Constants§

MAX_DEPTH
Maximum nesting depth accepted; above it the document is refused instead of overflowing the stack.

Functions§

array_items
The items of a list, each one as a text span.
decode_string
Decodes a JSON string (raw includes the quotes): escapes, \uXXXX and surrogate pairs.
object_fields
The fields of an object: decoded name and the text span of each value.
pretty
Re-indents a JSON document with two spaces, without touching the text of strings and numbers.
quote
Writes s as a JSON string, in quotes.
skip_value
Skips the value that starts at start (after spaces) and returns the index right after it.
validate
Checks that the whole of s is a single valid JSON value (surrounding spaces are accepted).