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.82k stars 215 forks source link

Unwanted behavior with array diff #215

Open NikolayMakhonin opened 5 years ago

NikolayMakhonin commented 5 years ago

Version 2.0.7

jsonpatch.compare([1,2,3,4,5,6,7,8], [1,2,3,4,0,5,6,7,8])

0: {op: "replace", path: "/7", value: 7} 1: {op: "replace", path: "/6", value: 6} 2: {op: "replace", path: "/5", value: 5} 3: {op: "replace", path: "/4", value: 0} 4: {op: "add", path: "/8", value: 8}

For comparison: https://chbrown.github.io/rfc6902/

rfc6902.createPatch([1,2,3,4,5,6,7,8], [1,2,3,4,0,5,6,7,8]);

0: { "op": "add", "path": "/4", "value": 0 }