Closed aachekalov closed 3 years ago
Hi!
I use JsonDiff with REARRANGE_ARRAYS option to minimize the difference. It works fine when it comes to adding a new item to the array. But with removing it produces cascade replaces.
JsonDiff
REARRANGE_ARRAYS
For example, I have 2 JSON to compare: Original:
{ "my_array": [ { "key": "qwerty" }, { "key": "asdfg" }, { "key": "zxcvb" } ] }
New:
{ "my_array": [ { "key": "asdfg" }, { "key": "zxcvb" } ] }
I'd like to have JSON Patch like that:
[ { "op": "remove", "path": "/my_array/0" } ]
but I get:
[ { "value": "qwerty", "op": "test", "path": "/my_array/0/key" }, { "value": "asdfg", "op": "replace", "path": "/my_array/0/key" }, { "value": "asdfg", "op": "test", "path": "/my_array/1/key" }, { "value": "zxcvb", "op": "replace", "path": "/my_array/1/key" }, { "op": "remove", "path": "/my_array/2" } ]
I suggest not to use array_values here: $newRearranged = array_values($newRearranged); because it breaks original indexes
array_values
$newRearranged = array_values($newRearranged);
Can you fix it please?
Thanks a lot!
Thank you for the issue and suggestion!
Please try v3.8.3.
v3.8.3
Works fine! Thanx!
Hi!
I use
JsonDiff
withREARRANGE_ARRAYS
option to minimize the difference. It works fine when it comes to adding a new item to the array. But with removing it produces cascade replaces.For example, I have 2 JSON to compare: Original:
New:
I'd like to have JSON Patch like that:
but I get:
I suggest not to use
array_values
here:$newRearranged = array_values($newRearranged);
because it breaks original indexesCan you fix it please?
Thanks a lot!