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.
RFC 8259 compliance
Section titled “RFC 8259 compliance”Strict JSON mode (parseJson) conforms to RFC 8259. String escaping, number parsing, whitespace handling, and duplicate-key behavior follow the spec.
JSONTestSuite
Section titled “JSONTestSuite”The parser is validated against the JSONTestSuite, the reference conformance corpus for JSON parsers:
| Category | Result |
|---|---|
| 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 and JSON5
Section titled “JSONC and JSON5”- JSONC strips line (
//) and block (/* */) comments before parsing. - JSON5 relaxes JSON syntax: trailing commas, unquoted keys, single-quoted strings, hexadecimal numbers, and
Infinity/NaNliterals.
Both modes use the same parse path as strict JSON and carry the same never-throw and well-formed guarantees.
Four-axis bar
Section titled “Four-axis bar”| Axis | Result |
|---|---|
| never-throw | 0 throws across 14,185 corpus files |
| well-formed | corpus WF = 0 |
| lossless | corpus lossless = 0 (BOM fixed) |
| conformance | JSONTestSuite: all y_, n_, i_* categories pass |