{"id":13652538,"url":"https://github.com/mikemccabe/json-patch-php","last_synced_at":"2025-04-23T03:30:53.176Z","repository":{"id":3821827,"uuid":"4902346","full_name":"mikemccabe/json-patch-php","owner":"mikemccabe","description":"PHP implementation of JSON-patch (IETF RFC 6902)","archived":false,"fork":false,"pushed_at":"2019-02-26T14:06:26.000Z","size":80,"stargazers_count":112,"open_issues_count":13,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-18T09:56:08.067Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikemccabe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-05T09:14:48.000Z","updated_at":"2024-06-10T10:58:32.000Z","dependencies_parsed_at":"2022-09-01T08:20:49.764Z","dependency_job_id":null,"html_url":"https://github.com/mikemccabe/json-patch-php","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemccabe%2Fjson-patch-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemccabe%2Fjson-patch-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemccabe%2Fjson-patch-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikemccabe%2Fjson-patch-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikemccabe","download_url":"https://codeload.github.com/mikemccabe/json-patch-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250365341,"owners_count":21418670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T02:01:00.246Z","updated_at":"2025-04-23T03:30:52.513Z","avatar_url":"https://github.com/mikemccabe.png","language":"PHP","funding_links":[],"categories":["Differencing"],"sub_categories":[],"readme":"json-patch-php\n================\n\nProduce and apply json-patch objects.\n\nImplements IETF JSON-patch (RFC 6902) and JSON-pointer (RFC 6901):\n\nhttp://tools.ietf.org/html/rfc6902\nhttp://tools.ietf.org/html/rfc6901\n\nUsing with Composer\n-------------------\n\nTo use this library as a Composer dependency in your project, include the\nfollowing sections in your project's `composer.json` file:\n\n```\n    \"repositories\": [\n        {\n            \"type\": \"vcs\",\n            \"url\": \"https://github.com/mikemccabe/json-patch-php\"\n        }\n    ],\n    \"require\": {\n        \"mikemccabe/json-patch-php\": \"dev-master\"\n    }\n```\n\nThen, in your project's code, use the `JsonPatch` class definition from\nthe `mikemccabe\\JsonPatch` namespace like so:\n\n```php\nuse mikemccabe\\JsonPatch\\JsonPatch;\n```\n\nEntry points\n------------\n\n- JsonPatch::get($doc, $pointer) - get a value from a json document\n- JsonPatch::patch($doc, $patches) - apply patches to $doc and return result\n- JsonPatch::diff($src, $dst) - return patches to create $dst from $src\n\nArguments are PHP arrays, i.e. the output of\njson_decode($json_string, 1)\n\n(Note that you MUST pass 1 as the second argument to json_decode to\nget an array.  This library does not work with stdClass objects.)\n\nAll structures are implemented directly as PHP arrays.  An array is\nconsidered to be 'associative' (e.g. like a JSON 'object') if it\ncontains at least one non-numeric key.\n\nBecause of this, empty arrays ([]) and empty objects ({}) compare the\nsame, and (for instance) an 'add' of a string key to an empty array\nwill succeed in this implementation where it might fail in others.\n\n$simplexml_mode is provided to help with working with arrays produced\nfrom XML in the style of simplexml - e.g. repeated XML elements are\nexpressed as arrays.  When $simplexml_mode is enabled, leaves with\nscalar values are implicitly treated as length-1 arrays, so this test\nwill succeed:\n\n    { \"comment\": \"basic simplexml array promotion\",\n      \"doc\": { \"foo\":1 },\n      \"patch\": [ { \"op\":\"add\", \"path\":\"/foo/1\", \"value\":2 } ],\n      \"expected\": { \"foo\":[1, 2] } },\n\nAlso, when $simplexml_mode is true, 1-length arrays are converted to\nscalars on return from patch().\n\nTests\n-----\n\nSome tests are in a submodule\n(https://github.com/json-patch/json-patch-tests).  Do 'git submodule\ninit' to pull these, then 'php runtests.php' to run them.\n\n\n[![Build Status](https://secure.travis-ci.org/mikemccabe/json-patch-php.png)](http://travis-ci.org/mikemccabe/json-patch-php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemccabe%2Fjson-patch-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikemccabe%2Fjson-patch-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemccabe%2Fjson-patch-php/lists"}