jsonlintdotcom
jsonlintdotcom copied to clipboard
Should fail or warn on duplicate field name
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.
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
Just hit this, not the worst of issues but it did catch me off guard. Fix would be nice.