Skip to content

Release 1.26.0

Choose a tag to compare

@reid-spencer reid-spencer released this 01 Jul 22:18

What's New

Features

  • root2Json — AST → JSON serializer (the inverse of parseJson)
    RiddlLib.root2Json(root, pretty) (and RiddlAPI.root2Json on the
    JavaScript side) serializes a RIDDL AST Root back into the JSON wire
    schema that parseJson consumes. 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 with bast2FlatAST, 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 in index.d.ts and
    JSON_INPUT.md.

Improvements

  • parseJson tolerates 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
      Username is 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 parseJson a far more forgiving input path for programmatic and
    AI-assisted generation, without loosening what a valid document means.