{"id":13470560,"url":"https://github.com/java-json-tools/json-patch","last_synced_at":"2025-12-17T21:52:40.039Z","repository":{"id":7558568,"uuid":"8911984","full_name":"java-json-tools/json-patch","owner":"java-json-tools","description":"An RFC 6902 (JSON Patch) and reverse, plus RFC 7386 (JSON Merge Patch), implementation in Java using Jackson (2.2.x)","archived":false,"fork":false,"pushed_at":"2024-03-25T14:42:28.000Z","size":666,"stargazers_count":627,"open_issues_count":64,"forks_count":182,"subscribers_count":27,"default_branch":"master","last_synced_at":"2024-05-20T22:50:10.926Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/java-json-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2013-03-20T18:59:36.000Z","updated_at":"2024-05-03T23:51:57.000Z","dependencies_parsed_at":"2024-05-02T20:57:45.180Z","dependency_job_id":"a18be894-fc61-4cab-901e-bc0d6ac36a09","html_url":"https://github.com/java-json-tools/json-patch","commit_stats":{"total_commits":272,"total_committers":14,"mean_commits":"19.428571428571427","dds":"0.11764705882352944","last_synced_commit":"55b27b96045baa4ef356b2b183304551f64a18e4"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-json-tools%2Fjson-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-json-tools%2Fjson-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-json-tools%2Fjson-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/java-json-tools%2Fjson-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/java-json-tools","download_url":"https://codeload.github.com/java-json-tools/json-patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222138882,"owners_count":16937422,"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-07-31T16:00:32.017Z","updated_at":"2025-12-17T21:52:40.031Z","avatar_url":"https://github.com/java-json-tools.png","language":"Java","readme":"[![License LGPLv3][LGPLv3 badge]][LGPLv3]\n[![License ASL 2.0][ASL 2.0 badge]][ASL 2.0]\n[![Build Status][Travis badge]][Travis]\n[![Maven Central][Maven Central badge]][Maven]\n\n## Read me first\n\nThis project, as of version 1.4, is licensed under both LGPLv3 and ASL 2.0. See\nfile LICENSE for more details. Versions 1.3 and lower are licensed under LGPLv3\nonly.\n\n**Note the \"L\" in \"LGPL\". LGPL AND GPL ARE QUITE DIFFERENT!**\n\n## What this is\n\nThis is an implementation of [RFC 6902 (JSON Patch)](http://tools.ietf.org/html/rfc6902) and [RFC\n7386 (JSON\nMerge Patch)](http://tools.ietf.org/html/rfc7386) written in Java,\nwhich uses [Jackson](https://github.com/FasterXML/jackson-databind) (2.2.x) at its core.\n\nIts features are:\n\n* {de,}serialization of JSON Patch and JSON Merge Patch instances with Jackson;\n* full support for RFC 6902 operations, including `test`;\n* JSON \"diff\" (RFC 6902 only) with operation factorization.\n\n## Versions\n\nThe current version is **1.13**. See file `RELEASE-NOTES.md` for details of releases before 1.11.\n\n## Using it in your project\n\nWith Gradle:\n\n```groovy\ndependencies {\n    compile(group: \"com.github.java-json-tools\", name: \"json-patch\", version: \"yourVersionHere\");\n}\n```\n\nWith Maven:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.java-json-tools\u003c/groupId\u003e\n    \u003cartifactId\u003ejson-patch\u003c/artifactId\u003e\n    \u003cversion\u003eyourVersionHere\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nVersions before 1.10 are available at `groupId` `com.github.fge`.\n\n## JSON \"diff\" factorization\n\nWhen computing the difference between two JSON texts (in the form of `JsonNode` instances), the diff\nwill factorize value removals and additions as moves and copies.\n\nFor instance, given this node to patch:\n\n```json\n{ \"a\": \"b\" }\n```\n\nin order to obtain:\n\n```json\n{ \"c\": \"b\" }\n```\n\nthe implementation will return the following patch:\n\n```json\n[ { \"op\": \"move\", \"from\": \"/a\", \"path\": \"/c\" } ]\n```\n\nIt is able to do even more than that. See the test files in the project.\n\n## Note about the `test` operation and numeric value equivalence\n\nRFC 6902 mandates that when testing for numeric values, however deeply nested in the tested value,\na test is successful if the numeric values are _mathematically equal_. That is, JSON texts:\n\n```json\n1\n```\n\nand:\n\n```json\n1.00\n```\n\nmust be considered equal.\n\nThis implementation obeys the RFC; for this, it uses the numeric equivalence of\n[jackson-coreutils](https://github.com/fge/jackson-coreutils).\n\n## Sample usage\n\n### JSON Patch\n\nYou have two choices to build a `JsonPatch` instance: use Jackson deserialization, or initialize one\ndirectly from a `JsonNode`. Examples:\n\n```java\n// Using Jackson\nfinal ObjectMapper mapper = new ObjectMapper();\nfinal InputStream in = ...;\nfinal JsonPatch patch = mapper.readValue(in, JsonPatch.class);\n// From a JsonNode\nfinal JsonPatch patch = JsonPatch.fromJson(node);\n```\n\nYou can then apply the patch to your data:\n\n```java\n// orig is also a JsonNode\nfinal JsonNode patched = patch.apply(orig);\n```\n\n### JSON diff\n\nThe main class is `JsonDiff`. It returns the patch as a `JsonPatch` or as a `JsonNode`. Sample usage:\n\n```java\nfinal JsonPatch patch = JsonDiff.asJsonPatch(source, target);\nfinal JsonNode patchNode = JsonDiff.asJson(source, target);\n```\n\n**Important note**: the API offers **no guarantee at all** about patch \"reuse\";\nthat is, the generated patch is only guaranteed to safely transform the given\nsource to the given target. Do not expect it to give the result you expect on\nanother source/target pair!\n\n### JSON Merge Patch\n\nAs for `JsonPatch`, you may use either Jackson or \"direct\" initialization:\n\n```java\n// With Jackson\nfinal JsonMergePatch patch = mapper.readValue(in, JsonMergePatch.class);\n// With a JsonNode\nfinal JsonMergePatch patch = JsonMergePatch.fromJson(node);\n```\n\nApplying a patch also uses an `.apply()` method:\n\n```java\n// orig is also a JsonNode\nfinal JsonNode patched = patch.apply(orig);\n```\n\n[LGPLv3 badge]: https://img.shields.io/:license-LGPLv3-blue.svg\n[LGPLv3]: http://www.gnu.org/licenses/lgpl-3.0.html\n[ASL 2.0 badge]: https://img.shields.io/:license-Apache%202.0-blue.svg\n[ASL 2.0]: http://www.apache.org/licenses/LICENSE-2.0.html\n[Travis Badge]: https://travis-ci.com/java-json-tools/json-patch.svg?branch=master\n[Travis]: https://travis-ci.com/java-json-tools/json-patch\n[Maven Central badge]: https://img.shields.io/maven-central/v/com.github.java-json-tools/json-patch.svg\n[Maven]: https://search.maven.org/artifact/com.github.java-json-tools/json-patch\n","funding_links":[],"categories":["Java","\u003ca name=\"Java\"\u003e\u003c/a\u003eJava"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjava-json-tools%2Fjson-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjava-json-tools%2Fjson-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjava-json-tools%2Fjson-patch/lists"}