Skip to main content

Module value

Module value 

Source
Expand description

JSON typed input (ADR-023 amended by ADR-060) with JCS-RFC8785 + Unicode NFC canonical-form byte output.

JSON canonicalization is not a streaming transform: JCS-RFC8785 §3.2.3 sorts object members lexicographically by key, which needs per-object storage. The realization therefore materializes the canonical form once, in an alloc buffer (canonicalize), with no width / depth / count ceilings: string widths, number widths, object-key counts, array-element counts, and total size are unbounded. The handle then flows through the pipeline as a zero-copy [TermValue::Borrowed] carrier over those canonical bytes, and ψ₉ folds them through the σ-axis. The single retained bound is MAX_JSON_DEPTH, a native-stack overflow guard on the recursive parser/canonicalizer.

JsonValue (the owned parsed value, alloc-gated) holds the structurally-tagged byte form and backs the JsonValueRef navigator used by the schema-pinned descendants; JsonCarrier is the borrowed model-input handle the pipeline binds.

§Tagged byte layout

JsonValue ::= Tag(1 byte) Payload
  Tag = 0x00 Null         — no payload
  Tag = 0x01 BoolFalse    — no payload
  Tag = 0x02 BoolTrue     — no payload
  Tag = 0x03 Number       — u32 BE length || N bytes (canonical ASCII)
  Tag = 0x04 String       — u32 BE length || N bytes (UTF-8, NFC)
  Tag = 0x05 Array        — u32 BE count  || count × JsonValue
  Tag = 0x06 Object       — u32 BE count  || count × (u32 BE keylen || key || JsonValue)

All multi-byte length / count fields are big-endian. Strings and object keys are NFC-normalized at parse time, so the canonical-form emitter is purely structural — it sorts object entries by NFC byte order and emits JCS syntax around already-canonical content.

Structs§

ArrayIter
Iterator over an array’s elements.
JsonCarrier
Borrowed canonical-JSON input handle (ADR-060 borrowed carrier). A thin, Copy borrow of canonical bytes produced by canonicalize; as_binding_value returns the Borrowed carrier zero-copy.
JsonValue
Owned parsed JSON value, holding the structurally-tagged byte form documented in the module header. Backs the JsonValueRef navigator. There is no width / depth / count ceiling. alloc-gated — the pipeline binds the borrowed JsonCarrier handle.
JsonValueRef
Zero-copy view into a tagged-byte JSON value (or sub-value), used by the schema-pinned descendants to validate JSON-LD admission predicates. Keys and string values are NFC-normalized; numbers carry their canonical ASCII text.
ObjectIter
Iterator over an object’s (key_bytes, value) entries.

Functions§

canonicalize
Parse + emit the JCS-RFC8785 + Unicode NFC canonical-form bytes.