-
Notifications
You must be signed in to change notification settings - Fork 31
Closed
Description
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.
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
Can you fix it please?
Thanks a lot!
vearutop
Metadata
Metadata
Assignees
Labels
No labels