Skip to main content

Module json_value

Module json_value 

Source
Expand description

Typed sum-type for parsed-data trees.

Replaces the ValueWord-tree return that pre-bulldozer parsers (json / yaml / toml / msgpack / xml) used. The strict-typed answer is a single concrete enum with the union of variants needed across all five formats; consumers pattern-match exhaustively.

Insertion order of Object fields is preserved by storing key-value pairs in a Vec rather than a HashMap. This matches the on-the-wire ordering of JSON / TOML / YAML / MsgPack and lets round-trip serialization stay byte-identical.

See docs/defections.md (2026-05-06 — typed JsonValue) for the rationale, and (2026-05-07 — N7 unified workstream — ε disposition) for the universal-intermediate role.

ADR-005: JsonValue is the parser-intermediate / wire-form translation layer, NOT a runtime storage type for user objects. Runtime objects live in HeapValue::TypedObject with a flat schema-driven slot array. The typed-parse path (__parse_typed) projects JsonValue to TypedObject before reaching user code; only the untyped json.parse path surfaces JsonValue to user code (as the Json enum in stdlib-src/core/json_value.shape). See docs/adr/005-typed-slot-construction.md.

Enums§

JsonValue

Functions§

heap_to_json_value
Walk a HeapValue tree and produce a JsonValue.
json_value_to_msgpack_bytes
Encode a JsonValue to MessagePack bytes.
json_value_to_serde_json
Convert a JsonValue into a serde_json::Value.
json_value_to_serde_yaml
Convert a JsonValue into a serde_yaml::Value.
json_value_to_toml_value
Convert a JsonValue into a toml::Value.