Skip to content

Releases: kasapdev/java-json-diff

v1.3.0

Choose a tag to compare

@kasapdev kasapdev released this 07 Sep 20:07

Added

  • JSON Patch (RFC 6902) generation and application. New JsonPatch class:
    • JsonPatch.generate(Object a, Object b) walks the same before/after values as JsonDiff.diff, but emits a standard RFC 6902 patch - a List<PatchOperation> of add/remove/replace operations addressed by real RFC 6901 JSON Pointer paths - instead of the library's own DiffEntry shape.
    • 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 new JsonPatchException when an operation's path doesn't resolve.
    • Array add/remove operations 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 PatchOp enum (ADD/REMOVE/REPLACE) and PatchOperation class (op(), path(), value(), plus toJsonObject() 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 ## Usage example.

v1.2.0

Choose a tag to compare

@kasapdev kasapdev released this 07 Sep 20:07
19120e4

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's LinkedHashMap/ArrayList on one side and a hand-built Map.of(...)/List.of(...) on the other, a common pattern when diffing parsed JSON against an "expected" value in a test - were reported as one coarse CHANGED entry 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.

v1.1.0

Choose a tag to compare

@kasapdev kasapdev released this 06 Sep 01:28

Adds edge-case regression tests: surrogate-pair unicode escapes, leading-zero rejection, duplicate object key handling, and JsonDiff on bare top-level scalars/arrays. No behavioral changes; all tests pass.

v1.0.0

Choose a tag to compare

@kasapdev kasapdev released this 05 Sep 23:41

Initial stable release.