#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

#343 in Development tools

Download history 250/week @ 2024-08-09 401/week @ 2024-08-16 418/week @ 2024-08-23 271/week @ 2024-08-30 294/week @ 2024-09-06 247/week @ 2024-09-13 323/week @ 2024-09-20 357/week @ 2024-09-27 737/week @ 2024-10-04 1153/week @ 2024-10-11 735/week @ 2024-10-18 835/week @ 2024-10-25 1019/week @ 2024-11-01 998/week @ 2024-11-08 558/week @ 2024-11-15 492/week @ 2024-11-22

3,176 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

~3.5–6MB
~105K SLoC