{"id":18550279,"url":"https://github.com/xp-forge/json-patch","last_synced_at":"2026-03-01T16:02:27.458Z","repository":{"id":34405727,"uuid":"38334476","full_name":"xp-forge/json-patch","owner":"xp-forge","description":"Implements JSON patch documents and JSON pointers","archived":false,"fork":false,"pushed_at":"2025-08-16T08:26:01.000Z","size":125,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-24T02:24:34.105Z","etag":null,"topics":["json-patch","json-pointer","php","rfc-6901","rfc-6902","xp-framework"],"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/xp-forge.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-30T21:39:14.000Z","updated_at":"2025-10-12T20:54:44.000Z","dependencies_parsed_at":"2024-11-06T21:04:08.691Z","dependency_job_id":"43c5d92e-6c22-48fe-80f9-f549584d9ac6","html_url":"https://github.com/xp-forge/json-patch","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/xp-forge/json-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fjson-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fjson-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fjson-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fjson-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xp-forge","download_url":"https://codeload.github.com/xp-forge/json-patch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xp-forge%2Fjson-patch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29974321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T15:41:30.362Z","status":"ssl_error","status_checked_at":"2026-03-01T15:37:07.343Z","response_time":124,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["json-patch","json-pointer","php","rfc-6901","rfc-6902","xp-framework"],"created_at":"2024-11-06T21:04:04.932Z","updated_at":"2026-03-01T16:02:27.452Z","avatar_url":"https://github.com/xp-forge.png","language":"PHP","readme":"JSON Patch\n==========\n\n[![Build status on GitHub](https://github.com/xp-forge/json-patch/workflows/Tests/badge.svg)](https://github.com/xp-forge/json-patch/actions)\n[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)\n[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)\n[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)\n[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)\n[![Latest Stable Version](https://poser.pugx.org/xp-forge/json-patch/version.svg)](https://packagist.org/packages/xp-forge/json-patch)\n\nImplements JSON patch documents described in [RFC #6902](http://tools.ietf.org/html/rfc6902) and JSON Pointer from [RFC #6901](http://tools.ietf.org/html/rfc6901). Tested against the spec available at https://github.com/json-patch/json-patch-tests. See also http://jsonpatch.com/. \n\nExample: JSON Patch\n-------------------\nThe entry point class is `text.json.patch.Changes`:\n\n```php\nuse text\\json\\patch\\{Changes, TestOperation, AddOperation};\n\n// You can create changes via maps...\n$changes= new Changes(\n  ['op' =\u003e 'test', 'path' =\u003e '/best', 'value' =\u003e 'Choco Liebniz'],\n  ['op' =\u003e 'add', 'path' =\u003e '/biscuits/1', 'value' =\u003e ['name' =\u003e 'Ginger Nut']]\n);\n\n// ...or by using Operation instances\n$changes= new Changes(\n  new TestOperation('/best', 'Choco Liebniz'),\n  new AddOperation('/biscuits/1', ['name' =\u003e 'Ginger Nut'])\n);\n\n// If you have a JSON patch document, use the spread operator\n$patch= [\n  ['op' =\u003e 'test', 'path' =\u003e '/best', 'value' =\u003e 'Choco Liebniz'],\n  ['op' =\u003e 'add', 'path' =\u003e '/biscuits/1', 'value' =\u003e ['name' =\u003e 'Ginger Nut']]\n];\n$changes= new Changes(...$patch);\n```\n\nAvailable operations are:\n\n* `AddOperation(string $path, var $value)` - The \"add\" operation performs one of the following functions, depending upon what the target location references.\n* `RemoveOperation(string $path)` - The \"remove\" operation removes the value at the target location.\n* `ReplaceOperation(string $path, var $value)` - The \"replace\" operation replaces the value at the target location with a new value. \n* `MoveOperation(string $from, string $to)` - The \"move\" operation removes the value at a specified location and adds it to the target location.\n* `CopyOperation(string $from, string $to)` - The \"copy\" operation copies the value at a specified location to the target location.\n* `TestOperation(string $path, var $value)` - The \"test\" operation tests that a value at the target location is equal to a specified value.\n\nTo apply the changes, call the `apply()` method and work with the result:\n\n```php\n$document= [\n  'best' =\u003e 'Choco Liebniz',\n  'biscuits' =\u003e [\n    ['name' =\u003e 'Digestive'],\n    ['name' =\u003e 'Choco Liebniz']\n  ]\n];\n\n$changed= $changes-\u003eapply($document);\n\n// $changed-\u003esuccessful() := true\n// $changed-\u003evalue() := [\n//  'best' =\u003e 'Choco Liebniz',\n//  'biscuits' =\u003e [\n//    ['name' =\u003e 'Digestive'],\n//    ['name' =\u003e 'Ginger Nut'],\n//    ['name' =\u003e 'Choco Liebniz']\n//  ]\n//];\n```\n\nExample: JSON Pointer\n---------------------\nYou can also use the \"raw\" functionality underneath the `Changes` instance.\n\n```php\nuse text\\json\\patch\\Pointer;\n\n$document= [\n  'biscuits' =\u003e [\n    ['name' =\u003e 'Digestive'],\n    ['name' =\u003e 'Choco Liebniz']\n  ]\n];\n\n$pointer= new Pointer('/biscuits/1');\n\n// $pointer-\u003eexists() := true\n// $pointer-\u003evalue() := ['name' =\u003e 'Ginger Nut'];\n\n// This will return an text.json.patch.Applied instance. Use its isError() \n// method to discover whether an error occurred.\n$result= $pointer-\u003emodify('Ginger Nut');\n\n// You can chain calls using the then() method. Closures passed to it will\n// only be invoked if applying the operation succeeds, otherwise an Error\n// will be returned.\n$result= $pointer-\u003eremove()-\u003ethen(function() use($pointer) {\n  return $pointer-\u003eadd('Choco Liebniz');\n});\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fjson-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxp-forge%2Fjson-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxp-forge%2Fjson-patch/lists"}