assert_jm

Macro assert_jm 

Source
macro_rules! assert_jm {
    ($actual:expr, { $($json:tt)* }) => { ... };
    ($actual:expr, [ $($json:tt)* ]) => { ... };
    ($actual:expr, $literal:literal) => { ... };
    ($actual:expr, null) => { ... };
    ($actual:expr, true) => { ... };
    ($actual:expr, false) => { ... };
    ($actual:expr, $expectation:expr) => { ... };
}
Expand description

“Assert json matches” Asserts that the given JSON in the first argument matches the JSON matcher defined by the second argument. Panics if the JSON does not match any expectations. Will print out each error encountered as well as the actual JSON encountered.

use serde_json::json;
use json_matcher::{assert_jm, AnyMatcher};

let test_data = json!({"name": "John", "age": 30});

// exact match against json defined in-line
assert_jm!(test_data, { "name": "John", "age": 30 });

// can also use non-exact "matchers"
assert_jm!(test_data, { "name": "John", "age": AnyMatcher::not_null() })