JSON Duplicate Keys

Jeremy Darling jeremy.darling at gmail.com
Thu Jun 6 06:31:02 PDT 2013


Copying in from another post I sent.  Instead of amending SHOULD to allow
parsers to throw new errors why not have them emit collections when
duplication is found?

Duplicate Keys should never have been allowed in the spec in the first
place (most all key/value stores don't allow it) or if they were allowed
when decomposed to JS objects they should have created arrays of values
much like most frameworks do for duplicate keys in the HTTP headers.

Thus, and typing this makes my skin crawl and my head hurt:

{
  "myKey": "Value 1",
  "myKey": 2
}

Becomes, upon parse:

{
  "myKey": ["Value 1", 2]
}

All values have now been accounted for. nothing has been created or lost,
and code that didn't take into account multiple keys but did type checking
on values will fail or adapt gracefully.

 - Jeremy



On Thu, Jun 6, 2013 at 8:02 AM, gaz Heyes <gazheyes at gmail.com> wrote:

> On 6 June 2013 13:19, Douglas Crockford <douglas at crockford.com> wrote:
>
>> 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.
>>
>
> Meh politics. I have no interest in such matters. Breaking broken programs
> shouldn't be a concern.
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130606/8af3f895/attachment.html>


More information about the es-discuss mailing list