You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When performing multiple move operations, the results from the jsonpatch formatter are not correct. Applying them does not results in the desired object.
Here is an example reversing the items in an array.
import{create}from'jsondiffpatch'import{format}from'jsondiffpatch/formatters/jsonpatch'importjsonpatchfrom'jsonpatch'constjsondiffpatch=create({arrays: {detectMove: true,},});consta=["first","second","third","fourth","fifth"];constb=["fifth","fourth","third","second","first"];constdiff=jsondiffpatch.diff(a,b);/*diff is { _t: 'a', _1: [ '', 3, 3 ], _2: [ '', 2, 3 ], _3: [ '', 1, 3 ], _4: [ '', 0, 3 ]}*/constpatchedwithdiff=jsondiffpatch.patch(a,diff)/*This is correct:patchedwithdiff is [ 'fifth', 'fourth', 'third', 'second', 'first' ]*/constpatch=format(diff,a)/*This is not correct:patch is: [ { op: 'move', from: '/1', path: '/3' }, { op: 'move', from: '/2', path: '/2' }, { op: 'move', from: '/3', path: '/1' }, { op: 'move', from: '/4', path: '/0' }]---There are many ways to get the desired results,but one way looks like this: [ { op: 'move', from: '/0', path: '/4' }, { op: 'move', from: '/0', path: '/4' }, { op: 'move', from: '/0', path: '/4' }, { op: 'move', from: '/0', path: '/4' }, { op: 'move', from: '/0', path: '/4' },]*/constpatchedwithjson=jsonpatch.apply_patch(a,patch)/*patchedwithjson is: [ 'first', 'fifth', 'fourth', 'third', 'second' ]we expected: ["fifth", "fourth", "third", "second", "first"]*/
The text was updated successfully, but these errors were encountered:
When performing multiple move operations, the results from the jsonpatch formatter are not correct. Applying them does not results in the desired object.
Here is an example reversing the items in an array.
The text was updated successfully, but these errors were encountered: