On Thu, Jun 6, 2013 at 9:31 AM, Jeremy Darling <[email protected]>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);
parsed.myKey.toUpperCase();
// TypeError
This is web breaking.
Rick
>
> - Jeremy
>
>
>
> On Thu, Jun 6, 2013 at 8:02 AM, gaz Heyes <[email protected]> wrote:
>
>> On 6 June 2013 13:19, Douglas Crockford <[email protected]> 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
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss