sort keys with JSON.stringify()

Brian Kardell bkardell at
Mon Sep 12 08:32:12 PDT 2011

I think depth shouldn't be the problem.  At the crux of is is that that
technique uses iteration order which has a bit of a defacto standard that
would "guarantee" that certain classes of object would serialize objects
with the same data in the same way.  It has problems on the fringes
though...if your data contains numeric keys or prototypes, for example.  I
say guarantee in quotes because sometimes a browser picks one of these
things that isn't written up and bucks tradition... Sometimes they are
punished because too much breaks, but sometimes not.
On Sep 12, 2011 8:10 AM, "Felipe Gasper" <felipe at> wrote:
> On 9/12/11 10:07 AM, Brian Kardell wrote:
>> 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).
> Almost. Actually, I want the converse: if two objects are equal, they
> serialize the same way.
> I noodled with the replacer function for a bit but wasn’t able to get
> something that seems to work for objects of arbitrary depth.
> -FG
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list