{"id":17045710,"url":"https://github.com/remorhaz/php-json-patch","last_synced_at":"2025-04-12T15:22:40.579Z","repository":{"id":57047026,"uuid":"73234517","full_name":"remorhaz/php-json-patch","owner":"remorhaz","description":"JSON Patch (RFC-6902) PHP implementation","archived":false,"fork":false,"pushed_at":"2024-02-21T21:33:07.000Z","size":80,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T10:01:28.258Z","etag":null,"topics":["json","jsonpatch","php","rfc-6902"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/remorhaz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-11-08T22:56:22.000Z","updated_at":"2025-03-19T17:56:30.000Z","dependencies_parsed_at":"2024-02-21T22:31:22.325Z","dependency_job_id":"130e30b0-2d6b-4c4d-b16a-1a204fdb5291","html_url":"https://github.com/remorhaz/php-json-patch","commit_stats":{"total_commits":42,"total_committers":4,"mean_commits":10.5,"dds":"0.23809523809523814","last_synced_commit":"fe154ecd1b65aa07a33ca1fcd31d01bd40ed35b5"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remorhaz%2Fphp-json-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remorhaz%2Fphp-json-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remorhaz%2Fphp-json-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remorhaz%2Fphp-json-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remorhaz","download_url":"https://codeload.github.com/remorhaz/php-json-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586727,"owners_count":21129092,"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":["json","jsonpatch","php","rfc-6902"],"created_at":"2024-10-14T09:38:10.065Z","updated_at":"2025-04-12T15:22:40.559Z","avatar_url":"https://github.com/remorhaz.png","language":"PHP","readme":"# PHP JSON Patch\n\n[![Latest Stable Version](https://poser.pugx.org/remorhaz/php-json-patch/v/stable)](https://packagist.org/packages/remorhaz/php-json-patch)\n[![Build](https://github.com/remorhaz/php-json-patch/actions/workflows/build.yml/badge.svg)](https://github.com/remorhaz/php-json-patch/actions/workflows/build.yml)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/remorhaz/php-json-patch/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/remorhaz/php-json-patch/?branch=master)\n[![codecov](https://codecov.io/gh/remorhaz/php-json-patch/branch/master/graph/badge.svg)](https://codecov.io/gh/remorhaz/php-json-patch)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fremorhaz%2Fphp-json-patch%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/remorhaz/php-json-patch/master)[![Total Downloads](https://poser.pugx.org/remorhaz/php-json-patch/downloads)](https://packagist.org/packages/remorhaz/php-json-patch)\n[![License](https://poser.pugx.org/remorhaz/php-json-patch/license)](https://packagist.org/packages/remorhaz/php-json-patch)\n\nThis library implements [RFC6902](https://tools.ietf.org/html/rfc6902)-compliant JSON patch tool.\n\n## Requirements\n- PHP 8.1.\n- [JSON extension](https://www.php.net/manual/en/book.json.php) (ext-json) - required by [remorhaz/php-json-data](https://github.com/remorhaz/php-json-data) to access JSON documents.\n- [Internationalization functions](https://www.php.net/manual/en/book.intl.php) (ext-intl) - required by [`remorhaz/php-json-data`](https://github.com/remorhaz/php-json-data) to compare Unicode strings.\n\n## Installation\nYou will need [composer](https://getcomposer.org) to perform install.\n```\ncomposer require remorhaz/php-json-patch\n```\n\n## Documentation\n### Accessing JSON document\nYou can create accessible JSON document either from encoded JSON string or from decoded JSON data using corresponding _node value factory_:\n```php\nuse Remorhaz\\JSON\\Data\\Value\\EncodedJson;\nuse Remorhaz\\JSON\\Data\\Value\\DecodedJson;\n\n// Creating document from JSON-encoded string:\n$encodedValueFactory = EncodedJson\\NodeValueFactory::create();\n$encodedJson = '{\"a\":1}';\n$document1 = $encodedValueFactory-\u003ecreateValue($encodedJson);\n\n// Creating document from decoded JSON data:\n$decodedValueFactory = DecodedJson\\NodeValueFactory::create();\n$decodedJson = (object) ['a' =\u003e 1];\n$document2 = $decodedValueFactory-\u003ecreateValue($decodedJson);\n```\n\n### Creating and processing query\nYou should use _query factory_ to create query from JSON Patch document. Then you should use _processor_ to apply that query:\n```php\n\u003c?php\nuse Remorhaz\\JSON\\Data\\Value\\EncodedJson;\nuse Remorhaz\\JSON\\Patch\\Processor\\Processor;\nuse Remorhaz\\JSON\\Patch\\Query\\QueryFactory;\n\n$encodedValueFactory = EncodedJson\\NodeValueFactory::create();\n$queryFactory = QueryFactory::create();\n$processor = Processor::create();\n\n$patch = $encodedValueFactory-\u003ecreateValue('[{\"op\":\"remove\",\"path\":\"/0\"}]');\n$query = $queryFactory-\u003ecreateQuery($patch);\n\n$document = $encodedValueFactory-\u003ecreateValue('[1,2]');\n$result = $processor-\u003eapply($query, $document);\n\nvar_dump($result-\u003eencode()); // string: '[2]'\nvar_dump($result-\u003edecode()); // array: [2]\n```\nNote that result can be exported either to JSON-encoded string or to raw PHP value.\n\n## License\nPHP JSON Patch is licensed under [MIT license](./LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremorhaz%2Fphp-json-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremorhaz%2Fphp-json-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremorhaz%2Fphp-json-patch/lists"}