stubr 0.6.2

Wiremock implemented in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use serde_json::Value;

use super::JsonMatcher;

pub struct JsonPathEqMatcher<'a>(pub &'a String, pub &'a Value);

impl<'a> JsonMatcher<'a> for JsonPathEqMatcher<'a> {
    fn matches(&self, json: &'a Value) -> bool {
        jsonpath_lib::select(json, self.0)
            .ok()
            .filter(|matched| !matched.is_empty())
            .filter(|matched| matched.iter().all(|&it| it == self.1))
            .is_some()
    }
}