Closed
Description
Hello, I'm getting the following error:
Exception/Stack Trace:
PHP Fatal error: Uncaught exception 'Swaggest\\JsonDiff\\Exception' with message
'Invalid key for array operation' in /usr/local/src/placelocal/vendor/swaggest/json-diff/src/JsonPointer.php:120
Stack trace:
#0 /usr/local/src/placelocal/vendor/swaggest/json-diff/src/JsonPatch.php(121): Swaggest\\JsonDiff\\JsonPointer::add(Object(stdClass), Array, 'missing value', false)
#1 /usr/local/src/placelocal/public_html/test.php(34): Swaggest\\JsonDiff\\JsonPatch->apply(Object(stdClass))
#2 {main}
thrown in /usr/local/src/placelocal/vendor/swaggest/json-diff/src/JsonPointer.php on line 120
Using php5.6, v3.4.0
Test Code:
$old = [
"key" => "diffvalue",
"nestedKey" => ["nestedKey" => "nesteddiffValue"],
"unchanged" => "value",
"new key" => "new value",
"new array" => ["new value3", "new value2"],
"notMissingKey" => [],
"appendKey" => ["value1", "value2"]
];
$new = [
"key" => "value",
"nestedKey" => ["nestedKey2" => "nestedValue"],
"unchanged" => "value",
"missingKey" => ["missingkey's child key" => "missing value"],
"notMissingKey" => ["nmk:missingkey" => "missing value", "nmk:missingkey2" => "missing value 2"],
"appendKey" => ["value1"]
];
$diff = new \Swaggest\JsonDiff\JsonDiff(json_decode(json_encode($old)), json_decode(json_encode($new)));
$patch = $diff->getPatch();
$test = json_decode(json_encode($old));
$patch->apply($test);
Metadata
Metadata
Assignees
Labels
No labels