json_diff_ng

Crates.iojson_diff_ng
lib.rsjson_diff_ng
version0.6.0
sourcesrc
created_at2023-10-09 07:05:36.469866
updated_at2024-05-30 20:27:27.386667
descriptionA JSON diff library, featuring deep-sorting and key exclusion by regex. CLI is included.
homepagehttps://github.com/ChrisRega/json-diff
repositoryhttps://github.com/ChrisRega/json-diff
max_upload_size
id997721
size2,546,886
Christopher Regali (ChrisRega)

documentation

README

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

Commit count: 90

cargo fmt