philiprehberger-json-diff 0.1.8

Structural JSON diff with path tracking for Rust
Documentation

rs-json-diff

CI Crates.io GitHub release Last updated License Bug Reports Feature Requests Sponsor

Structural JSON diff with path tracking for Rust

Installation

[dependencies]
philiprehberger-json-diff = "0.1.8"

Usage

use philiprehberger_json_diff::{diff, diff_summary};
use serde_json::json;

let a = json!({
    "name": "Alice",
    "age": 30,
    "tags": ["rust", "dev"]
});

let b = json!({
    "name": "Alice",
    "age": 31,
    "tags": ["rust", "senior"],
    "active": true
});

let changes = diff(&a, &b);
for change in &changes {
    println!("{}", change);
}

let summary = diff_summary(&changes);
println!("Added: {}, Removed: {}, Modified: {}", summary.added, summary.removed, summary.modified);

API

Item Description
diff(a: &Value, b: &Value) -> Vec<Change> Compute structural diff between two JSON values
diff_summary(changes: &[Change]) -> DiffSummary Summarize a list of changes by type counts
ChangeType Enum: Added, Removed, Modified
Change Struct with path, change_type, old_value, new_value
DiffSummary Struct with added, removed, modified counts

Development

cargo test
cargo clippy -- -D warnings

Support

If you find this package useful, consider giving it a star on GitHub — it helps motivate continued maintenance and development.

LinkedIn More packages

License

MIT