jsonlintdotcom icon indicating copy to clipboard operation
jsonlintdotcom copied to clipboard

Should fail or warn on duplicate field name

Open benkant opened this issue 13 years ago • 2 comments

When I validate the following code on JSONlist.com:

{
    "keya": 1,
    "keyb": 0,
    "keya": 0
}

It reports valid JSON. The last value "keya" is taken and the previous is ignored. Some JSON libraries do the same, but AFNetworking in particular fails for duplicate field names.

JSlint reports:

Problem at line 4 character 5: Duplicate 'keya'.

"keya": 0

JSON: bad.

benkant avatar Nov 17 '11 22:11 benkant

if you do something like this:

{"function": {"replace": {"column": "NAME", "esc_string": "-", "esc_string":"_"}}}

then it will call it valid but the reformatting engine will drop the duplicate. I think it should just warn cuz this is valid JSON for us, but the reformat should not drop the dup for you

gillyspy avatar Feb 26 '12 19:02 gillyspy

Just hit this, not the worst of issues but it did catch me off guard. Fix would be nice.

esuomi avatar May 28 '12 13:05 esuomi