JSONFilter
jsonfilter
is a Rust crate designed to facilitate filtering and comparing JSON values based on specified criteria. It provides functions for comparing JSON values, applying filters to JSON objects, and determining if a filter matches a given JSON object. Think of MongoDBs find()
function but as a filter function. For a full syntax guide, see the Filter Documentation
Usage
To use jsonfilter
, add it to your Cargo.toml
and add the following to your Rust code:
use ;
Comparing JSON Values
You can compare two JSON values using the order
function:
use json;
use Ordering;
use order;
let a = json!;
let b = json!;
assert_eq!;
Matching Filters
To check if a JSON object matches a filter, use the matches
function:
use json;
use matches;
let filter = json!;
let obj = json!;
assert!;