Releases: kasapdev/java-json-diff
Releases · kasapdev/java-json-diff
Release list
v1.3.0
Added
- JSON Patch (RFC 6902) generation and application. New
JsonPatchclass:JsonPatch.generate(Object a, Object b)walks the same before/after values asJsonDiff.diff, but emits a standard RFC 6902 patch - aList<PatchOperation>ofadd/remove/replaceoperations addressed by real RFC 6901 JSON Pointer paths - instead of the library's ownDiffEntryshape.JsonPatch.apply(Object before, List<PatchOperation> patch)is a general-purpose RFC 6902 applier: it replays a patch against a document to produce the patched result, without mutating the input. It supports mid-array insertion, the"-"append marker, and throws the newJsonPatchExceptionwhen an operation's path doesn't resolve.- Array
add/removeoperations are ordered so a patch is safe to apply sequentially: growth is emitted as ascending appends, shrinkage as descending removes (removing highest-index-first so earlier removes never invalidate a later operation's index). - New
PatchOpenum (ADD/REMOVE/REPLACE) andPatchOperationclass (op(),path(),value(), plustoJsonObject()for the{"op", "path", "value"}wire shape). - Proven with a round-trip test: diffing two nontrivial nested documents (objects, arrays, additions, removals, replacements, and keys requiring JSON Pointer escaping), generating a patch from that diff, applying it to the "before" document, and asserting the result equals "after" exactly - both by value equality and independently via
JsonDiff.diff(...).isEmpty(). - README: new "JSON Patch (RFC 6902)" section with a runnable diff -> generate -> apply -> round-trip example, plus an additional
## Usageexample.
v1.2.0
Fixed
JsonDiff.diff()no longer requires both sides of an object/array to be the exact same Java runtime class in order to recurse into them. Previously, two Maps (or two Lists) with identical structure but different concrete implementations - e.g.JsonParser'sLinkedHashMap/ArrayListon one side and a hand-builtMap.of(...)/List.of(...)on the other, a common pattern when diffing parsed JSON against an "expected" value in a test - were reported as one coarseCHANGEDentry for the entire value instead of being diffed key-by-key / index-by-index. Recursion now keys off JSON "kind" (instanceof Map/instanceof List) instead of exact class equality.