Structural diffs between JSON documents with path-based change tracking
implementation com.philiprehberger:json-diffStructural diffs between JSON documents with path-based change tracking.
implementation("com.philiprehberger:json-diff:0.1.4")
<dependency>
<groupId>com.philiprehberger</groupId>
<artifactId>json-diff</artifactId>
<version>0.1.4</version>
</dependency>
import com.philiprehberger.jsondiff.*
val diff = jsonDiff(
"""{"name":"Alice","age":30}""",
"""{"name":"Alice","age":31,"email":"a@b.com"}"""
)
diff.modified() // [Change(MODIFIED, "$.age", 30, 31)]
diff.added() // [Change(ADDED, "$.email", null, "a@b.com")]
| Function / Class | Description |
|---|---|
jsonDiff(old, new, config) | Compute structural diff between two JSON strings |
DiffResult.hasChanges() | Check if any differences exist |
DiffResult.added() / removed() / modified() | Filter changes by type |
Change | Single change with type, path, oldValue, newValue |
DiffConfig.ignoreArrayOrder | Treat arrays as unordered sets |
DiffConfig.ignorePaths | Paths to exclude from comparison |
./gradlew test
./gradlew build
If you find this project useful: