use jsonfilter::{try_matches, FilterError}; use serde_json::json; fn main() { let filter = json!({"name": "John", "other": "key"}); let obj = json!({"name": "John", "age": 30}); println!("Applying filter:"); println!("{}", filter); println!("To object:"); println!("{}", obj); match try_matches(&filter, &obj) { Ok(result) => { if result { println!("Filter matches the object"); } else { println!("Filter does not match the object"); } } // FilterError::KeyNotFound mostly means the object did not pass the filter, but it's still an error though Err(err) => match err { FilterError::InvalidFilter => println!("Invalid filter"), FilterError::UnknownOperator => println!("Unknown operator in filter"), FilterError::KeyNotFound => println!("Key not found in object"), }, } }