Skip to main content

jsonpath_canonical

Function jsonpath_canonical 

Source
pub fn jsonpath_canonical(input: &str) -> Result<String, EvalError>
Expand description

Encode a Value as its canonical JSON text (no surrounding quotes for non-strings). Used by every builder below.

Rules:

  • NULL → “null” (json literal; NOT SQL NULL).
  • BOOL → “true” / “false”.
  • Numbers → bare decimal text (BigInt prints exact 64-bit form).
  • Text → quoted+escaped JSON string.
  • Json/Jsonb → pass-through (assumed valid; parser is forgiving).
  • Arrays → “[..,..]” with element-wise encoding.
  • Bytes / Date / Timestamp / Uuid / Numeric → quoted textual form via Display; PG canonical text shape. v7.39 (read01 jsonpath.c) — canonicalize a jsonpath literal the way PG’s jsonpath output function does: lax is the implicit default and is not printed, strict is; field accessors always print quoted ($."a"); filters print as ?(@ <op> <val>) with spaces around the operator; last - k keeps its spaces. Errors surface as 22P02-shaped syntax errors.