Field guide · RFC 8259 and I-JSON

JSON Interoperability Guide

Valid JSON can still behave differently after it reaches another runtime. These small fixtures show where source information can be hidden or changed—and what the formatter reports before conversion.

Fixture 01

Duplicate member names

{
  "role": "reader",
  "role": "admin"
}

RFC 8259 says object names should be unique, but this text is still accepted by many parsers. Once it becomes a typical language object or map, one value may replace the other. Which value remains is not reliably portable.

JSONClarity’s behavior: both entries retain their order, raw key spelling, value, and line/column. The second entry is linked back to the first. Repair never deletes either member.

Pointer caveat: RFC 6901 JSON Pointer names a member by its decoded key. It cannot uniquely address two members with the same name, so a copied pointer is marked ambiguous rather than extended with a proprietary syntax.

Local query grammar

The supported JSONPath subset

A query beginning with $ uses a deliberately small, non-executable subset. Plain text without $ searches decoded keys, primitive previews, and JSON Pointers instead.

  • $ selects the root;
  • $.name selects a simple object member;
  • $['any key'] and $["any key"] use bracket-quoted names;
  • $[0] selects an array index and $[*] expands one level;
  • $..name recursively selects a member name;
  • $..* recursively selects descendants.

Filters, scripts, slices, unions, functions, and mutation are intentionally disabled. Results keep source order, retain duplicate members, and stop at 500 matches. The visible result list mounts 24 at a time; refine the query to inspect more. Selecting a result does not run code or change the JSON, and copying produces an RFC 6901 JSON Pointer—not a claim that JSONPath and JSON Pointer are interchangeable.

Fixture 02

Numbers beyond a shared safe model

{
  "id": 9007199254740993,
  "rate": 0.12345678901234567890
}

The JSON grammar does not impose JavaScript’s numeric storage model. The integer is two greater than the largest integer in the usual interoperable safe range, and one greater than 253. The decimal carries more significant digits than common binary64 consumers preserve.

JSONClarity’s behavior: formatting emits the same raw number lexemes. The parser records risks before any optional object-like interpretation. It does not round, normalize an exponent, remove trailing decimal zeroes, or turn a number into a string.

Fixture matrix

Strict JSON versus familiar lookalikes

InputJSONWhyControlled response
{"a":1,}InvalidNo trailing comma grammar.Preview removing the final comma.
{"a":1 // note}InvalidComments are not JSON tokens.Preview removing the comment; re-parse strictly.
{'a':1}InvalidStrings use double quotes.Review conversion; escape intent may differ.
{a:1}InvalidObject names are strings.Review quoting a simple key.
{"a":NaN}InvalidNaN is not a JSON value.Manual only; null would invent meaning.
{"a":undefined}Invalidundefined is not JSON.Manual only.

Fixture 03

Unicode, BOMs, escapes, and controls

Escapes are source, not decoration

"a" and "\u0061" decode to the same key, so they count as duplicates in one object. Their original spellings remain different and are preserved by formatting.

Surrogate code units

A valid high/low surrogate pair represents a supplementary Unicode character. An isolated surrogate can pass the JSON grammar as an escape yet fail to represent a Unicode scalar value; the formatter keeps it and adds an interoperability warning instead of guessing a replacement.

Control characters and BOM

U+0000 through U+001F must be escaped inside strings. A leading U+FEFF byte-order mark is tolerated with a warning and can be removed only as an explicit repair. The same character elsewhere is not treated as ordinary JSON whitespace.

Source fidelity

Member order is useful even when semantics call objects unordered

Object order is not a portable semantic contract, but source order still carries practical value during review, diffs, debugging, and hand-edited configuration. The formatter preserves that order by default.

Sort keys is separate: enabling it marks the output as intentionally reordered. It never removes duplicates, never reorders arrays, and turning it off restores source order because the source tree was not mutated.

One guide, not one page per message

Common JSON errors and what a location means

Trailing comma{"ok":true,}

The error points at the comma. Its removal is deterministic when the next significant token closes that same object or array.

Unexpected end{"items":[1,2

The final offset is known, but the intended number and kind of closing tokens may not be. No structure is invented.

Missing quotes{status:"ok"}

A simple unquoted key can become a reviewable candidate. An unterminated string remains manual when its intended endpoint is unclear.

Invalid escape{"path":"C:\logs"}

The error identifies the backslash and unsupported escape. The tool does not assume whether a literal slash or escaped control was intended.

Raw controlline break inside a string

The character’s line and column are reported. A closed string can receive a visible escape proposal.

Comment{"ok":true /* why */}

Removal can be proposed, but only the strict parser decides whether the selected preview is valid.

Repair contract

A proposal is not a correction

Every candidate has a source range, before/after text, explanation, and confidence. Preview applies selected edits to a copy and sends that copy through the strict parser. Apply is a separate user action. Undo restores the exact previous source text.

Before  { "ready": True, }
        -              ^  ^
Review  +              true
        -                  ,
After   { "ready": true }

The tool deliberately rejects “easy-looking” guesses such as converting undefined to null, resolving a duplicate member, rounding a number, inserting a missing complex comma, or closing an uncertain string.

Primary references

Specifications behind these checks

These links are the normative sources. The examples above are original fixtures and concise explanations, not substitutes for the specifications.

Reproducibility

How behavior is tested

Each engine fixture states the exact source, expected validity, diagnostic code, source offset, line/column, and expected formatted lexemes. Unit tests run the pure TypeScript engine. Browser tests cover the worker, file limits, repair review, tree search, storage, network canaries, keyboard flow, responsive layouts, and accessibility.

A public source link, cross-runtime comparison table, and browser/device benchmark claims will be added only after an official publication location and a dated, reproducible matrix exist. This local build does not invent either.

Try the local formatter with these fixtures