Skip to content

JSON Conformance

Lanexio Parser supports three JSON-family grammars through a single package: strict JSON (RFC 8259), JSONC (JSON with comments), and JSON5 (ECMAScript 5 relaxations). All three share the same never-throw parse path and zero-copy flat AST.

Strict JSON mode (parseJson) conforms to RFC 8259. String escaping, number parsing, whitespace handling, and duplicate-key behavior follow the spec.

The parser is validated against the JSONTestSuite, the reference conformance corpus for JSON parsers:

CategoryResult
y_* (must accept)All pass — never-throw, root is not Error
n_* (must reject)All pass — parse succeeds but root is Error
i_* (implementation-defined)All pass — never-throw, caller decides semantics

The JSON grammar is never-throw: malformed input produces a tree with an Error root node rather than throwing an exception. Callers inspect tree.root.hasError to determine parse success.

  • JSONC strips line (//) and block (/* */) comments before parsing.
  • JSON5 relaxes JSON syntax: trailing commas, unquoted keys, single-quoted strings, hexadecimal numbers, and Infinity/NaN literals.

Both modes use the same parse path as strict JSON and carry the same never-throw and well-formed guarantees.

AxisResult
never-throw0 throws across 14,185 corpus files
well-formedcorpus WF = 0
losslesscorpus lossless = 0 (BOM fixed)
conformanceJSONTestSuite: all y_, n_, i_* categories pass