The JSON spec does not forbid repeating a key, so every library picks its own behaviour. I ran one response through five parsers today:
{"orderId":5002,"status":"PAID","amount":2970,"status":"CANCELLED"} | Parser | Result |
|---|---|
Python json.loads | status = CANCELLED |
Node JSON.parse | status = CANCELLED |
| Jackson 2.17, default | status = CANCELLED |
Jackson 2.17 with STRICT_DUPLICATE_DETECTION | error: Duplicate field 'status' |
| org.json 20231013 | JSONException: Duplicate key "status" |
Two Java services reading the same payload disagree: one sees a cancelled order, the other throws. Nobody sees PAID, even though it is right there in the response. A schema check passes, and a field test on status is green in every language that silently collapses the repeat.
How to catch it
- Python:
json.loads(text, object_pairs_hook=...)and fail on repeated keys. - Jackson: enable
JsonParser.Feature.STRICT_DUPLICATE_DETECTION, at least in tests. - API responses in general: check the raw response text, not only the parsed object.
- Service boundaries: agree that a repeated key is a contract error, not "last one wins".
The payload is order 5002 in our practice API, if you want to try it with your own client: https://checkcraft.ru/en/guides/api-testing-practice.html
Have you hit this in production? Which side turned out to be right?

