On Dec 7, 2013, at 7:22 PM, John Cowan wrote:

> Allen Wirfs-Brock scripsit:
> 
>> In other words, ECMA-262 explicitly specifies that when multiple
>> occurrences of the same member name occurs in a JSON object, the value
>> associated with the last (right-most) occurrence is used. Order matters.
> 
> Okay, I concede that order matters *when* there are duplicate names.
> I still deny that it matters otherwise.

In reality it defines the JavaScript for-in enumeration order over the JS 
object property generated by JSON.parse.

Try this in your favorite browser:

   var jText = '{"b": 1, "a": 2, "c": 3};
   for (var key in JSON.parse(jText) console.log(key);

You will get as output:
     b
     a
     c

I can assure you that code exists on the web that depends, whether 
intentionally or not, on this ordering.  Past experience among browser 
implementations is that site break when attempts are made to change this 
ordering.

Allen


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to