Macro assert_json_diff::assert_json_matches [−][src]
Compare two JSON values according to a configuration.
use assert_json_diff::{ CompareMode, Config, NumericMode, assert_json_matches, }; use serde_json::json; let config = Config::new(CompareMode::Strict).numeric_mode(NumericMode::AssumeFloat); assert_json_matches!( json!({ "a": { "b": [1, 2, 3.0] }, }), json!({ "a": { "b": [1, 2.0, 3] }, }), config, )
When using CompareMode::Inclusive
the first argument is actual
and the second argument is
expected
. Example:
// This assert_json_matches!( json!({ "a": { "b": 1 }, }), json!({ "a": {}, }), Config::new(CompareMode::Inclusive), ); // Is the same as this assert_json_include!( actual: json!({ "a": { "b": 1 }, }), expected: json!({ "a": {}, }), );