Skip to main content

Module json

Module json 

Source
Expand description

v4.14 minimal JSON parser for the -> / ->> operators.

Hand-rolled, no external dep — same policy as the rest of the engine. Supports the JSON grammar from RFC 8259: objects, arrays, strings (with \" / \\ / \/ / \b / \f / \n / \r / \t / \uXXXX escapes), numbers, true / false / null. The parser returns a tree we walk by key (object) or integer index (array); accesses that miss return Value::Null per PG semantics.

path_get(doc, key, as_text) is the public entry. When as_text is true (->> operator), JSON strings unwrap to raw text and other scalars render as their canonical text; when false (->), the result is wrapped back into a Json value (the inner subtree rendered to its canonical JSON string form).

Enums§

JsonValue
ParseError

Functions§

contains
v6.4.5 — PG json @> sub_json containment. Returns BOOL. lhs @> rhs is true when every member of rhs is structurally contained in lhs:
parse
path_get
PG json -> key / json ->> key. lhs must be JSON or TEXT containing JSON. rhs is either a TEXT key (object access) or an INT index (array access). as_text=true for ->> (returns Value::Text); false for -> (returns Value::Json).
path_walk
v6.4.5 — PG json #> path_text / json #>> path_text. The right-hand side is a PG text-array literal '{a,0,b}' whose elements are walked left-to-right; each element is either an object key or (when it parses as a non-negative integer) an array index. Missing or non-existent steps return Value::Null.