primitive

Macro primitive 

Source
macro_rules! primitive {
    ($matcher:expr) => { ... };
}
Expand description

Matches a JSON string, number, or boolean against the given matcher.

§Examples

let data = j!({"active": true, "count": 3, "small": 12i8, "limit": 65000u16});
verify_that!(data["active"], json::primitive!(eq(true)));
verify_that!(data["count"], json::primitive!(ge(0)));
verify_that!(data["small"], json::primitive!(eq(12i8)));
verify_that!(data["limit"], json::primitive!(eq(65000u16)));

§Errors

Fails when the JSON value is not a string, number, or boolean.