JSON Duplicate Keys
waldron.rick at gmail.com
Thu Jun 6 06:45:48 PDT 2013
On Thu, Jun 6, 2013 at 9:31 AM, Jeremy Darling <jeremy.darling at gmail.com>wrote:
> 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.
This breaks extant data value invariants. Ignoring the original question
and addressing only this example, let's say the expected value was a string
(your example shows a string and a number)
var parsed = JSON.parse(data);
This is web breaking.
> - 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
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss