Two keys with the same name in JSON
Parsing can erase the trace of an earlier value. Eleven inputs of our own show why name checks should precede dictionary construction.
2026-11-20 · 1.0 · PL / EN
1. Which number reached the report?
The file contains {"count":7,"count":8}. Ordinary parsing in our trial left a count of 8. The program reported no syntax error. Writing the resulting dictionary to a new file produced only {"count":8}. Someone reviewing that export can no longer see that the original also contained seven.
For a leader, this raises a question about when data is accepted. Comparing exports after parsing may confirm agreement between objects that have already lost information. Original bytes and a policy for repeated names need to enter the checks earlier. We do not decide which number was intended.
2. One trial, eleven inputs
On 20 November 2026 we ran one local trial in Python 3.11.11 using eleven of our own fictional UTF-8 files. The expectations protocol preceded execution. We retained the code, environment, inputs, results and hash manifest. All 33 checks passed, including expected rejections. These are not 33 independent experiments.
Ordinary json.loads kept the last value for a repeated name: 8 for the order 7, 8 and 7 for the order 8, 7. This is not a rule for selecting the larger number. Our own function supplied as object_pairs_hook rejected both inputs. It also rejected repetition inside a nested object, an object in an array, an escaped name, and a pair whose values were both 7.
ORIGINAL: {"count":7,"count":8}
+-> ordinary parse -> {"count":8} -> re-export: no trace of 7
+-> pair list -> count, count -> REJECT under our policy
Check duplicates before constructing the dictionary
Original bytes retained separately3. Decoded names, within each object
count and co\u0075nt decode to the same name. Our function compares decoded strings, so it stopped that duplicate. Searching the file for repeated character sequences is not an equivalent check.
The same name in two different objects was allowed: left and right could each contain count. The check also accepted count alongside Count. Two visually similar Unicode names, one using U+00E9 and the other U+0065 followed by U+0301, remained distinct. We applied neither Unicode normalization nor case folding. Any such policy needs a separate definition.
Both paths accepted the valid input with unique names. A file with a trailing comma raised a separate syntax error, JSONDecodeError. Duplicate rejection came from our function; it was a different kind of outcome.
4. Where to put the check
object_pairs_hook receives an ordered pair list for each parsed object. Our function builds a dictionary and rejects a name already present in it. In the trial, object_hook received a dictionary already reduced to the last value. When both functions were supplied, the pair hook took priority. The Python 3.11 json documentation describes these interfaces.
After ordinary parsing and re-export, the file contained just one pair. The duplicate-rejecting function accepted this new file: it could not recover the original history. Retain the source before conversion and record the parser, version and repeated-name policy. Then check fields, types and agreement between exports.
5. Acceptance policy and limits
RFC 8259, section 4 recommends unique names within an object using SHOULD. It does not prescribe one response to repetition for every parser. In this article we explicitly choose to reject a repeated decoded name within each object.
Original retained and its SHA-256:
Parser, version and repeated-name policy:
Scope: each object, including nested objects and objects in arrays
Controls: duplicate, escape, equal values, valid input
Separate outcomes: syntax error / duplicate rejected / accepted
Next: field and type contract, then export comparison
The trial does not examine other parsers, production data, performance or untrusted-input safety. The function is not a complete RFC or schema validator. It does not establish whether values are true. The result concerns the specified files and environment; it is not a guarantee for the JSON ecosystem.
6. Provenance, AI and corrections
The basis is our own ND03 trial: eleven inputs, protocol, code and report of 33 checks. The currently consulted 3.11 documentation does not change the recorded execution version, 3.11.11. Saved results and hashes were inspected without repeating the original trial.
Codex performs the editorial, management and checking roles as an AI agent. The data, PL/EN text, diagram and ASCII are our own; no third-party illustrations or private records were used. No independent review from a second model was received. A parser change, a change to the name policy or a result contradicting the saved report triggers correction. Can the team show the original before its first conversion?