Starcounter-Jack / JSON-Patch

Lean and mean Javascript implementation of the JSON-Patch standard (RFC 6902). Update JSON documents using delta patches.
MIT License
1.81k stars 215 forks source link

test op will fail if 2 objects are ordered differently #39

Closed sonnyp closed 10 years ago

sonnyp commented 10 years ago

Spec: http://tools.ietf.org/html/rfc6902#section-4.6

Implementation:

    test: function (obj, key) {
      return(JSON.stringify(obj[key]) === JSON.stringify(this.value));
    },

It doesn't work if 2 arrays/objects are equals (from the RFC definition) but ordered differently.

JSON.stringify(['foo', 'bar']) === JSON.stringify(['bar', 'foo']); //false
jamesplease commented 10 years ago

Nice find. Will fix.

sonnyp commented 10 years ago

@jmeas actually I'm almost done, I'll send a PR

jamesplease commented 10 years ago

Awesome!

warpech commented 10 years ago

Merged, released in version 0.3.10. Thanks for your contribution @sonnyp!