You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then, in your project's code, use the JsonPatch class definition from
the mikemccabe\JsonPatch namespace like so:
usemikemccabe\JsonPatch\JsonPatch;
Entry points
JsonPatch::get($doc, $pointer) - get a value from a json document
JsonPatch::patch($doc, $patches) - apply patches to $doc and return result
JsonPatch::diff($src, $dst) - return patches to create $dst from $src
Arguments are PHP arrays, i.e. the output of
json_decode($json_string, 1)
(Note that you MUST pass 1 as the second argument to json_decode to
get an array. This library does not work with stdClass objects.)
All structures are implemented directly as PHP arrays. An array is
considered to be 'associative' (e.g. like a JSON 'object') if it
contains at least one non-numeric key.
Because of this, empty arrays ([]) and empty objects ({}) compare the
same, and (for instance) an 'add' of a string key to an empty array
will succeed in this implementation where it might fail in others.
$simplexml_mode is provided to help with working with arrays produced
from XML in the style of simplexml - e.g. repeated XML elements are
expressed as arrays. When $simplexml_mode is enabled, leaves with
scalar values are implicitly treated as length-1 arrays, so this test
will succeed: