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 |
Corpus conformance
Section titled “Corpus conformance”pnpm conformance:suite measured this family over the test_files/json corpus on 2026-10-06 at
Lanexio™ Parser version 1.0.0:
| family | valid | invalid | raw | contract-subset | REAL-DEFECT |
|---|---|---|---|---|---|
| json | 18951 | 233 | 98.4% | 100.0% (18646/18646) | 0 |
The contract-subset is artifact-adjusted: 305 valid-classified files report an error, and each is accounted for by one of three documented buckets, so none is silently dropped and the REAL-DEFECT count is 0. Every bucketed file still reports an error node, so acceptance behavior is unchanged.
| Bucket | Files | Rule |
|---|---|---|
json5-generated-malformed-numeric | 294 | Path under test_files/json5/generated/, basename doc_*.json5, and a numeric token with a second decimal point (/\.\d+\.\d+/). |
lone-surrogate-escape-policy | 10 | A \uD800-\uDFFF escape that is not the lead or trail half of a valid surrogate pair (RFC 8259 section 8.2 permits the ABNF; corpus/json/i_policy.md emits an error node). |
mislabeled-valid-fixture-unbalanced | 1 | Path under test_files/json/edge-cases/ with unequal brace counts. |
The raw figure counts both directions over every classified file; the 1 invalid-classified input that is not flagged is included in the raw denominator.