Function httptest::matchers::json_decoded

source ·
pub fn json_decoded<T, M>(inner: M) -> JsonDecoded<T, M>
where M: Matcher<T>,
Expand description

json decode the input and pass the resulting value to the inner mapper. If the input cannot be decoded a false value is returned.

This can be used with Fn matchers to allow for flexible matching of json content. The following example matches whenever the body of the request contains a json list of strings of length 3.

§Example

use httptest::matchers::*;

request::body(json_decoded(|b: &Vec<String>| b.len() == 3));