sort keys with JSON.stringify()
Brian Kardell
bkardell at gmail.com
Mon Sep 12 08:07:32 PDT 2011
But Doug, just to clarify: You mean that the parsed objects create no
predictable insertion order right? It is actually possible to use replacer
to serialize keys in a particular order, and that might be enough for what
he is looking for (if two objects serialized as the same string they would
be equal).
Perhaps I am over simplifying his question or I misunderstand your response.
On Sep 11, 2011 3:05 PM, "Douglas Crockford" <douglas at crockford.com> wrote:
> On 11:59 AM, Felipe Gasper wrote:
>> Is it possible to get sorted keys:
>>
>> {a:1,c:3}
>>
>> …from running JSON.stringify when declaring an object thus:
>>
>> {c:3,a:1}
> JSON objects are unordered. If order is important, then use an array.
> _______________________________________________
> 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/20110912/b8806bbc/attachment.html>
More information about the es-discuss
mailing list