Package com.flipkart.zjsonpatch


package com.flipkart.zjsonpatch
Core zjsonpatch API for JSON Patch operations according to RFC 6902.

This package provides the main public APIs for creating and applying JSON patches. The library supports both Jackson 2.x and Jackson 3.x with separate API entry points.

API Selection

Users must explicitly use the correct public API based on their Jackson version:

Separate APIs are necessary because:

  1. The original API is based on Jackson 2.x types and cannot be changed without breaking compatibility
  2. A unified API is not possible since only one Jackson version may be available in the classpath with incompatible package structures

Basic Usage

For Jackson 2.x:


 // Create JSON nodes using Jackson 2.x ObjectMapper
 JsonNode source = mapper.readTree("{\"foo\":\"bar\"}");
 JsonNode target = mapper.readTree("{\"foo\":\"baz\"}");
 
 // Generate and apply patch
 JsonNode patch = JsonDiff.asJson(source, target);
 JsonNode result = JsonPatch.apply(patch, source);
 

For Jackson 3.x:


 // Create JSON nodes using Jackson 3.x ObjectMapper
 JsonNode source = mapper.readTree("{\"foo\":\"bar\"}");
 JsonNode target = mapper.readTree("{\"foo\":\"baz\"}");
 
 // Generate and apply patch
 JsonNode patch = Jackson3JsonDiff.asJson(source, target);
 JsonNode result = Jackson3JsonPatch.apply(patch, source);
 
See Also: