has_path_with

Macro has_path_with 

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

Matches a JSON leaf at the given path against the provided matcher.

The path uses the same dot-and-escape rules as has_paths. The matcher can be a literal, a serde_json::Value, or any native googletest matcher.

§Examples

let value = j!({"user": {"id": 7, "name": "Ada"}});
assert_that!(
    value,
    json::has_path_with!("user.name", "Ada")
        .and(json::has_path_with!("user.id", j!(7)))
        .and(json::has_path_with!("user.name", starts_with("A")))
);

§Supported Inputs

  • Literal JSON-compatible values
  • Direct serde_json::Value
  • Native googletest matchers

§Errors

Fails when the path is invalid, missing, the value is not an object, or the leaf does not satisfy the matcher.