#json-diff #json #diff #json-structural-diff

bin+lib json_diff_ng

A JSON diff library, featuring deep-sorting and key exclusion by regex. CLI is included.

9 releases (4 breaking)

0.6.0 May 30, 2024
0.6.0-RC1 May 22, 2024
0.5.0 May 3, 2024
0.4.1 Mar 17, 2024
0.2.0 Oct 9, 2023

#352 in Development tools

Download history 172/week @ 2024-06-12 173/week @ 2024-06-19 222/week @ 2024-06-26 82/week @ 2024-07-03 39/week @ 2024-07-10 78/week @ 2024-07-17 69/week @ 2024-07-24 216/week @ 2024-07-31 257/week @ 2024-08-07 338/week @ 2024-08-14 432/week @ 2024-08-21 332/week @ 2024-08-28 295/week @ 2024-09-04 278/week @ 2024-09-11 269/week @ 2024-09-18 361/week @ 2024-09-25

1,248 downloads per month
Used in havocompare

Unlicense

2.5MB
996 lines

json-diff-ng

Crates.io Documentation CI Coverage Status License

Contributors:

Contributors

Library

json_diff_ng can be used to get diffs of json-serializable structures in rust.

Usage example

use json_diff::compare_strs;
let data1 = r#"["a",{"c": ["d","f"] },"b"]"#;
let data2 = r#"["b",{"c": ["e","d"] },"a"]"#;
let diffs = compare_strs(data1, data2, true, & []).unwrap();
assert!(!diffs.is_empty());
let diffs = diffs.unequal_values.get_diffs();
assert_eq!(diffs.len(), 1);
assert_eq!(
    diffs.first().unwrap().to_string(),
    r#".[0].c.[1].("f" != "e")"#
);

See docs.rs for more details.

CLI

json-diff is a command line utility to compare two jsons.

Input can be fed as inline strings or through files.
For readability, output is neatly differentiated into three categories: keys with different values, and keys not present in either of the objects.
Only missing or unequal keys are printed in output to reduce the verbosity.

Usage Example:

$ json_diff file source1.json source2.json
$ json_diff direct '{...}' '{...}'

Option:

file : read input from json files
direct : read input from command line

Installation

$ cargo install json_diff_ng

Dependencies

~4–6MB
~108K SLoC