Duplicate JSON keys: check the response before trusting its value

The saved response says pending. Your analysis script says closed. Before treating that as a change in the source, check whether the response contains the same field name twice. A decoder may have quietly selected one value while building the object your script reads.

Preserve the original response first. Then check for repeated decoded names inside each object, before reducing its members to a dictionary. If two values collide, report the ambiguity instead of choosing whichever value your usual software happens to keep.

Two identical blank key shapes attached to different colored panes beneath a magnifying glass
Generated conceptual illustration of competing field values; it is not a captured JSON response.

A field can repeat without looking identical

This is a fictional teaching record, not evidence about a real case or service:

{"case":"DEMO-17","status":"pending","sta\u0074us":"closed"}

The escape \u0074 represents the letter t. After decoding, both names are status. A search for two literal occurrences of "status" in the raw text would miss the collision. A screenshot of a formatted viewer might show only one value.

RFC 8259 recommends unique names within an object and describes differing receiver behavior when they repeat. Its string-comparison discussion also explains why escape processing matters. “The file parsed successfully” therefore does not establish that every original member survived in the result.

Reject the collision before building a dictionary

Run this small example locally with Python 3.12. It uses a fixed synthetic input and reads no network resource. The first print demonstrates the default result; the second decoding uses our explicit rejection rule.

import json

# Fictional, bounded teaching input; not a live service response.
raw = rb'{"case":"DEMO-17","status":"pending","sta\u0074us":"closed"}'

def unique_object(pairs):
    result = {}
    for name, value in pairs:
        if name in result:
            raise ValueError(f"Repeated member: {name!r}")
        result[name] = value
    return result

if len(raw) > 4096:
    raise ValueError("Input exceeds this exercise's size limit")

print(json.loads(raw)["status"])  # closed: default decoding
try:
    json.loads(raw, object_pairs_hook=unique_object)
except ValueError as error:
    print(error)  # Repeated member: 'status'

The Python documentation describes the default last-value behavior. object_pairs_hook lets the check examine the ordered member pairs before creating the dictionary. The function runs for nested objects too. A fresh result is built for each object, so names in separate objects do not collide with one another.

Our rule deliberately stops even when the duplicate values agree. That is a review policy for this exercise: a repeated name deserves examination before analysis continues. It does not mean every consumer must reject the file, or that a duplicate proves deliberate tampering.

The 4,096-byte check bounds this exercise’s input. It is not a general resource-control scheme or a complete JSON conformance validator. For example, this snippet does not change Python’s separate handling of nonstandard number constants. Keep it focused on the duplicate-name question.

Try three variations

InputExpected result with our ruleWhy
{"status":"pending","status":"pending"}RejectThe name repeats even though its values agree.
[{"status":"pending"},{"status":"closed"}]AcceptEach object has its own member names.
{"Status":"pending","status":"closed"}AcceptCapitalization differs; our check does not merge the names.

These variations prevent two common mistakes: searching for duplicates across the entire document and lowercasing every name before comparison. An application’s own schema may forbid Status or require a particular field, but that is a separate check. Do not silently rewrite keys and then describe the rewritten object as the source response.

Keep the raw evidence separate from the interpretation

Save the received body with its source URL, retrieval time and relevant response metadata before sending it through a formatter or export tool. Retain the raw file and make a separate working copy. A SHA-256 record helps identify which bytes were examined; it cannot decide which of two status values the publisher intended.

If the only surviving artifact is a normalized dictionary containing closed, the earlier pending value cannot be recovered from that dictionary alone. Obtain the original response or label that evidence gap. Re-running a current endpoint might produce a different snapshot and should not be presented as the lost historical body.

For the teaching record, a defensible finding is: “The preserved body contains two members that decode to the name status, with values pending and closed. Default decoding retained closed; the duplicate-name check rejected the object. This record alone does not establish one unambiguous case status.”

Add the raw body, parser version, check code and result to the evidence section of your report. The useful next question is whether a clean source record or documented correction resolves the conflict. Until then, the conflict belongs in the finding.

Author: OSINT Jet · Primary sources reviewed 21 November 2026