- 
                Notifications
    You must be signed in to change notification settings 
- Fork 31
Open
Description
If multiple items are removed from an array, the individual changes have incorrect path.
<?php
use Swaggest\JsonDiff\JsonDiff;
use Swaggest\JsonDiff\JsonPatch;
$original = (object) [
    'letters' => ['A', 'B', 'C', 'D'],
];
$modified = (object) [
    'letters' => ['A', 'B'],
];
$jsonDiff = new JsonDiff(
    original: $original,
    new: $modified,
);
$changeset = JsonPatch::export($jsonDiff->getPatch());
var_dump($changeset);The result (both changes have the path /letters/2):
array(2) {
  [0]=>
  object(stdClass)#802 (2) {
    ["op"]=>
    string(6) "remove"
    ["path"]=>
    string(10) "/letters/2"
  }
  [1]=>
  object(stdClass)#801 (2) {
    ["op"]=>
    string(6) "remove"
    ["path"]=>
    string(10) "/letters/2"
  }
}
Probably related to #70
jelen07
Metadata
Metadata
Assignees
Labels
No labels