Release 1.26.0
What's New
Features
root2Json— AST → JSON serializer (the inverse ofparseJson) —
RiddlLib.root2Json(root, pretty)(andRiddlAPI.root2Jsonon the
JavaScript side) serializes a RIDDL ASTRootback into the JSON wire
schema thatparseJsonconsumes. For any model in the supported subset the
round-trip is faithful:parseJson(root2Json(root))re-validates
identically, and the serialization is stable under a second round-trip. It
is lossless for the documented JSON subset and best-effort (non-crashing)
beyond it. Combined withbast2FlatAST, existing compiled models can now be
turned into JSON — e.g. to mint training data for AI generation. Implemented
as a plain recursive serializer (JsonSerializer), Native-safe, and
additive (no existing signatures change). Documented inindex.d.tsand
JSON_INPUT.md.
Improvements
-
parseJsontolerates the two most common AI-generated JSON mistakes —
Real language models emitting model JSON reliably make two schema-usage
slips that previously failed to parse; both are now accepted (strictly more
permissively — every previously-valid document parses identically):- An unknown type-expression
kind(e.g.{"kind":"Username"}where
Usernameis a declared type) is read as a reference to a declared type of
that name instead of raising an error. Genuinely undefined names still
surface as normal validation (resolution) errors when the model is
validated — never as an exception. - Inline cardinality,
{"kind":"Date","cardinality":"optional"}, is now
accepted and parses identically to the canonical wrapper form
{"cardinality":"optional","of":{"kind":"Date"}}.
This makes
parseJsona far more forgiving input path for programmatic and
AI-assisted generation, without loosening what a valid document means. - An unknown type-expression