Property Iteration in JSON serialization

Brian Kardell bkardell at gmail.com
Wed Oct 14 09:27:21 PDT 2009


On Wed, Oct 14, 2009 at 5:41 AM, Patrick Mueller <pmuellr at yahoo.com> wrote:
> On Oct 14, 2009, at 2:42 AM, Oliver Hunt wrote:
>
>> All ES implementations are required to enumerate object properties in the
>> order of insertion, regardless of internal representation, and the JSON
>> object definition defines the replacer execution in terms of that standard
>> object enumeration.
>
> I understand that's what all (or most) of the implementations actually do,
> but the ES5 spec I'm looking at - Ecma/TC39/2009/043 - doesn't actually say
> it's required.
>
> In 12.6.4 discussing the for-in statement, it says: "The mechanics and order
> of enumerating the properties (step 6.a in the first algorithm, step 7.a in
> the second) is not specified."
>
> In 15.2.3.14 discussion Object.keys(), it says: "If an implementation
> defines a specific order of enumeration for the for-in statement, that same
> enumeration order must be used in step 5 of this algorithm."
>
> In 15.12.2 discussing JSON.parse(), it says: "The ordering of the Strings
> should be the same as that used by the Object.keys standard built-in
> function."
>
> In 15.12.3 discussing JSON.stringify(), it says: "The ordering of the
> Strings should be the same as that used by the Object.keys standard built-in
> function."
>
> Sorry, property ordering is an unfortunate pet peeve of mine.  :-)
>
> Patrick Mueller - http://muellerware.org/
>
>

Uh oh... Patrick looking at the same parts as me reacting the same way
(I believe older pre-5 docs also said something similar)...
When Oliver said "All ES implementations are required to..." I assumed
that I missed something in the new 5 docs - not that everyone just
seems to have implemented roughly the same thing...

Is it required - or is it not?


More information about the es-discuss mailing list