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§
Functions§
- build_
array json_build_array(...)— variadic; empty → “[]”. Each arg encoded viavalue_to_json_text.- build_
object json_build_object(k, v, k, v, …)— variadic, even-length. NULL key → error (PG: “argument cannot be null”). Values encoded viavalue_to_json_text. Returns Value::Json.- contains
- v6.4.5 — PG
json @> sub_jsoncontainment. Returns BOOL.lhs @> rhsis true when every member ofrhsis structurally contained inlhs: - insert
jsonb_insert(target, path, new_value [, insert_after])— insert at path.insert_afterdefaults to false.- parse
- path_
get - PG
json -> key/json ->> key.lhsmust be JSON or TEXT containing JSON.rhsis either a TEXT key (object access) or an INT index (array access).as_text=truefor->>(returnsValue::Text);falsefor->(returnsValue::Json). - path_
query - v7.17.0 Phase 3.9 —
jsonb_path_query(doc, path)— returns the matched JSON values as a TextArray (each element is the JSON encoding of one match). - path_
query_ array - v7.17.0 Phase 3.9 —
jsonb_path_query_array(doc, path)returns the matched values wrapped as a single JSON array. - path_
query_ first - v7.17.0 Phase 3.9 —
jsonb_path_query_first(doc, path)returns the first matched JSON value as a Json, or NULL on no match. - 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 returnValue::Null. - set
jsonb_set(target, path, new_value [, create_missing])— replace at PG text-array path.create_missingdefaults to true.- value_
to_ json_ text - Encode a Value as its canonical JSON text (no surrounding quotes for non-strings). Used by every builder below.