macro_rules! optional {
($inner:expr) => { ... };
}Expand description
Matches a JSON field that may be absent, null, or satisfy an inner matcher.
§Examples
let value = j!({ "id": 42 });
assert_that!(
value,
json::pat!({
"id": eq(42),
"nickname": json::optional!("Bob"),
"alt": json::optional!(j!("Robert")),
"tag": json::optional!(starts_with("B"))
})
);§Supported Inputs
- Literal JSON-compatible values
- Direct
serde_json::Value - Native googletest matchers