JSON and data guides

Duplicate JSON keys: prevent parser disagreement

Detect repeated member names before parsing discards evidence, and define a consistent rejection policy.

Nav Tools ·

Syntax acceptance is not agreement

RFC 8259 says object names should be unique. Implementations may keep the last value, reject the document, or expose repeated members.

A successful syntax check therefore cannot prove that every downstream parser will interpret the same object.

{"enabled":false,"enabled":true}
JSON.parse(...) → {enabled: true}

Inspect the original document

Keep the raw response while investigating. Once a parser has produced an object, serializing it cannot recover a discarded member.

Use Text Diff to compare raw fixtures and JSON Formatter for readability. The site does not provide a dedicated duplicate-member detector.

Compare decoded names

A JSON escape changes the representation of a character, not the property name. A and its Unicode escape can therefore name the same member.

A detector must understand JSON strings and nesting; a regular expression over quoted text can mistake values for keys or miss escaped quotes.

{"A":1,"\u0041":2}
Both decoded member names are A.

Reject at the trust boundary

Choose a parser or streaming validator that rejects duplicate decoded names in each object. Include nested objects in your fixtures.

Apply the same policy before signing, authorizing or forwarding a payload. Formatter output is useful evidence but cannot certify this policy.

References

← JSON and data guides