Do JSON keys need to be unique?
This question already has an answer here:
There is no "error" if you use more than one key with the same name, but in JSON, the last key with the same name is the one that is going to be used.
In your case, the key "name" would be better to contain an array as it's value, instead of having a number of keys "name". It doesn't make much sense the same object or "thing" to have two names, or two of the same properties that are in conflict.
Eg:
{
"name" : [ "JOHN", "JACK", "...", ... ]
}
From RFC 4627:
An object structure is represented as a pair of curly brackets surrounding zero or more name/value pairs (or members). A name is a string. A single colon comes after each name, separating the name from the value. A single comma separates a value from a following name. The names within an object SHOULD be unique.
jQuery is able to parse it. But if you try to access it, it's just giving back the last value.
Check out http://jsfiddle.net/MQmM4/2/
So, it's parsable, I guess, but the value gets overridden if you use the same key.
链接地址: http://www.djcxy.com/p/37824.html下一篇: JSON密钥是否必须是唯一的?