assert_json_matches

Function assert_json_matches 

Source
pub fn assert_json_matches(actual: &Value, pattern: &Value) -> bool
Expand description

Assert that a value matches a JSON pattern (partial matching).

The pattern only needs to contain the fields you want to verify. Extra fields in the actual value are ignored.

§Example

let actual = json!({"id": 123, "name": "Test", "extra": "ignored"});
assert!(assert_json_matches(&actual, &json!({"id": 123})));
assert!(assert_json_matches(&actual, &json!({"name": "Test"})));