Expand description
Native json module for JSON parsing and serialization.
Exports: json.parse(text), json.stringify(value, pretty?), json.is_valid(text)
parse(text) always returns a typed Json enum value. The legacy
json_value_to_nanboxed untyped fallback was removed in sweep phase 4a.
Schema-driven parsing (__parse_typed) coerces JSON directly into a
TypedObject for the supplied schema; nested unknown objects fall back to
the typed Json enum rather than an untyped HashMap.
Phase-2d strict-typing migration status (Stage D close-out batch, 2026-05-07):
json.parse(text) -> Result<Json>— MIGRATED at Stage D Step 4. Body builds the strict-typedJsonValueenum (crate::json_value::JsonValue) directly fromserde_json::Valueand wraps withTypedReturn::Ok(ConcreteReturn::JsonValue(...))per Stage D Step 1’sConcreteReturn::JsonValuevariant addition (commita022f43). N6 sub-shape (b1) sign-off; closes B1 sub-decision #2 for json.parse.json.__parse_typed(text, schema_id) -> Result<any>— MIGRATED at Stage D close-out Step 3. Body buildsHeapValue::TypedObjectdirectly from the runtime schema + JSON object viabuild_typed_object_from_json, then wraps theArc<HeapValue>inConcreteReturn::OpaqueTypedObjectper close-out Step 2’s variant addition (commit1bca2c4). N8 sign-off; closes B1 sub-decision #2 for json.__parse_typed. The 5 legacy ValueWord-using helpers (make_json_enum / json_value_to_enum / json_object_to_typed / json_value_to_typed_nb / json_value_to_typed_json_enum) were DELETED at close-out Step 3 — verified call-graph private to__parse_typedbefore deletion.json.stringify(value: any, pretty?: bool) -> Result<string>— DEFERRED pending N7 (HeapValue→JSON serializer for HTTP / object-output marshal contexts). N7 is the unified workstream covering HTTP post_json/put_json + yaml/toml/msgpack stringify/encode/encode_bytes (6 consumers total). Body uses deletedto_json_value()+ would need the N7 serializer.json.is_valid(text) -> bool— Migratable in isolation but kept deferred for per-file atomicity; lands with stringify when N7 sign-off unblocks the residual json cohort.
N7 is supervisor-level; queued for next-session relay batch (see
docs/defections.md HashMap-marshal cluster sub-decision queue
2026-05-07 Stage B+D close-out subsection).
Strict-typed helpers serde_json_to_json_value (used by json.parse),
build_json_enum_heap_value, build_field_slot_from_json, and
build_typed_object_from_json (used by __parse_typed) construct
ValueSlots directly from native types via the ValueSlot::from_*
primitives — no ValueWord intermediate, no call to nb_to_slot.
Note: nb_to_slot (defined pub(crate) at
crate::type_schema::mod) and adjacent slot-construction code in
type_schema/mod.rs still cite the deleted ValueWord API. That
cleanup is N9 candidate — type_schema/mod.rs slot-construction-
layer migration. Tracked separately for next-session pickup; this
commit explicitly does NOT touch type_schema/mod.rs (verification
gate caught the cross-cutting concern; Option A2 chosen over A1 to
preserve per-file atomicity).
Functions§
- create_
json_ module - Create the
jsonmodule with JSON parsing and serialization functions.