Couldn't this cause some problems if the key:val pairs aren't written
out in the same order?

var obj1 = { cool:'sauce', abc:1 };
var obj2 = { abc:1, cool:'sauce' };

JSON.encode(obj1);
// returns "{"cool":"sauce","abc":1}"

JSON.encode(obj2);
// returns "{"abc":1,"cool":"sauce"}"

Even though technically speaking, they both have 'identical
data' (whatever that means :) )

On Jun 6, 2:32 pm, Fábio M. Costa <[email protected]> wrote:
> yeah, i do it the same way.
>
> --
> Fábio Miranda Costa
> Solucione Sistemas
> Engenheiro de interfaces
> Twitter: fabiomirandahttp://solucione.info
>
>
>
> On Sun, Jun 6, 2010 at 6:15 PM, Ryan Florence <[email protected]> wrote:
> > That's how I do it.
>
> > Sent from my iPhone
>
> > On Jun 6, 2010, at 2:38 PM, אריה גלזר <[email protected]> wrote:
>
> >  OK. so i need a "as efficient as possible" solution to compare 2 objects.
> >> A note is that i'm coparing objects that come from JSON, so they can only
> >> hold JSONable values.
> >> what i'm doing right now is simply JSON.encode them and then compare the
> >> strings. I am assuming that for browser with native json support this 
> >> should
> >> be faster than iterating them both (especially true for objects, which need
> >> to be checked by keys as well).
> >> Do you think this method is a good one? is there a better way of doing
> >> this?
>
> >> --
> >> Arieh Glazer
> >> אריה גלזר
> >> 052-5348-561
> >> 5561

Reply via email to