GitHub - gamringer/JSONPatch: A RFC6902 compliant JSON Patch PHP implementation (original) (raw)
JSONPointer
A RFC6902 compliant JSON Patch PHP implementation
#License JSONPatch is licensed under the MIT license.
#Installation
composer require gamringer/php-json-patch
##Tests
#Documentation
##Operations can be constructed and applied independently
operation−>apply(operation->apply(operation−>apply(target); ##Operations can also be constructed from a JSON string addOperation(new \gamringer\JSONPatch\Operation\Add('/foo', 'bar')); $patch->addOperation(new \gamringer\JSONPatch\Operation\Test('/foo', 'bar')); ##A patch can also be constructed from a JSON string patch−>apply(patch->apply(patch−>apply(target); var_dump($target); /* Results: array(1) { 'foo' => string(3) "bar" } */ If the patch fails, it gets completely reverted and an exception is thrown. patch−>apply(patch->apply(patch−>apply(target); } catch (\gamringer\JSONPatch\Exception $e) { var_dump($target); } /* Results: array(0) {} */