* Allen Wirfs-Brock wrote:
>On Dec 7, 2013, at 4:55 PM, John Cowan wrote:
>> Allen Wirfs-Brock scripsit:
>> 
>>> Similarly, the JSON texts:
>>>   {"1":  1, "2", 2}
>>> and
>>>   {"2":  2, "1": 1}
>>> 
>>> or the JSON texts:
>>>   {"a": 1, "a": 2}
>>> and
>>>   {"a": 2, "a": 1}
>>> 
>>> have an ordering of the object members that must be preserved by the
>>> parser in order for downstream semantics to be applied.
>> 
>> I cannot accept this statement without proof.  Where in the ECMAscript
>> definition does it say this?

>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.
>
>A similar analysis applies to the first example.  

Your analysis does not demonstrate that `JSON.parse` preserves ordering.
I am confident that even in the current ES6 draft `JSON.stringify` does
not preserve ordering even if `JSON.parse` somehow did. It's based on
`Object.keys` which does not define ordering as currently proposed. If
you can re-create the key-value-pair order in your first example from
the output of `JSON.parse` without depending on implementation-defined
behavior, seeing the code for that would be most instructive.
-- 
Björn Höhrmann · mailto:[email protected] · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to