sort keys with JSON.stringify()

David Bruant david.bruant at labri.fr
Sun Sep 11 10:55:48 PDT 2011


Key orders is supposed to follow the order used in Object.keys (step 6
after "The abstract operation /JO/(/value/) serializes an object.")
which is the order of for-in loops which is supposed to be
implementation specific.

However, engines have, in practice, followed more or less the same way
of ordering keys which means that there would be some de-facto standard
that the commitee is discussing to standardize (as far as I know). See
http://wiki.ecmascript.org/doku.php?id=strawman:enumeration (and
discussion at the end)

David

Le 11/09/2011 04:14, Felipe Gasper a écrit :
> Hello,
>
>     Is it possible to get sorted keys:
>
> {a:1,c:3}
>
> …from running JSON.stringify when declaring an object thus:
>
> {c:3,a:1}
>
> ??
>
> -FG
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110911/0857173b/attachment.html>


More information about the es-discuss mailing list