JSON Duplicate Keys
douglas at crockford.com
Thu Jun 6 05:19:44 PDT 2013
On 6/6/2013 5:00 AM, gaz Heyes wrote:
> On 6 June 2013 12:29, Douglas Crockford <douglas at crockford.com
> <mailto:douglas at crockford.com>> wrote:
> The JSON RFC says
> The names within an object SHOULD be unique.
> interpreted SHOULD to mean DON'T HAVE TO. In a perfect world, we
> would change the SHOULD to MUST, but we can't. Interoperability
> and security concerns demand that we specify what happens when
> keys are duplicated. So we may end up with something like this:
> The names within an object SHOULD be unique. If a key is
> a parser SHOULD reject. If it does not reject, it MUST take
> only the
> last of the duplicated key pairs.
> Does anyone see a problem with this?
> That doesn't make sense "should" should be "must" because if it's
> taking the last key then you can overwrite someone else's data.
You are exactly right. But it is too late to change to MUST unless TC39
chooses to break the programs of the people who are doing what they
shouldn't, which is something TC39 said it will not do.
More information about the es-discuss