aogriffiths / jsondiff-js

A JavaScript implementation to create json patches of the JSON Media Type for partial modifications: http://tools.ietf.org/html/draft-ietf-appsawg-json-patch-08. See also https://github.com/bruth/jsonpatch-js.
https://github.com/aogriffiths/jsondiff-js
BSD 2-Clause "Simplified" License
23 stars 11 forks source link

Array differences for property named `list` #2

Closed dolphin278 closed 10 years ago

dolphin278 commented 11 years ago

A little weird thing — if you have property named list that is an array, jsondiff-js does not generates differences for them:

jsondiff.diff(
        { a: 1, list: [1,2,3]},
        { b: 'abc', list: [123]}
)

produces

[ { op: 'add', path: '/b', value: 'abc' },
  { op: 'remove', path: '/a' } ]

and if we rename list to just l everything works just fine:

jsondiff.diff(
        { a: 1, l: [1,2,3]},
        { b: 'abc', l: [123]}
)

produces

[ { op: 'add', path: '/b', value: 'abc' },
  { op: 'remove', path: '/a' },
  { op: 'remove', path: '/l/1' },
  { op: 'remove', path: '/l/2' },
  { op: 'replace', path: '/l/0', value: 123 } ]