8 releases (4 breaking)

0.5.1 Mar 5, 2020
0.5.0 Dec 6, 2019
0.4.0 Dec 4, 2019
0.3.0 Nov 30, 2019
0.1.2 Nov 26, 2019

#1992 in Parser implementations

Download history 25/week @ 2024-06-27 62/week @ 2024-07-04 63/week @ 2024-07-11 119/week @ 2024-07-18 40/week @ 2024-07-25 32/week @ 2024-08-01 2/week @ 2024-08-08 15/week @ 2024-08-15 31/week @ 2024-08-22 33/week @ 2024-08-29 33/week @ 2024-09-05 30/week @ 2024-09-12 37/week @ 2024-09-19 80/week @ 2024-09-26 34/week @ 2024-10-03 5/week @ 2024-10-10

158 downloads per month

MIT license

115KB
2.5K SLoC

jsonlogic_rs   Build Status Latest Version

A JsonLogic implementation in Rust.

To use this library, add

[dependencies]
jsonlogic = "0.5"

to your Cargo.toml.

Usage

use serde_json::{json, Value};

let rule = json!({
    "===": [
        2,
        { "var": "foo" }
    ]
});

let data = json!({ "foo": 2 });
assert_eq!(jsonlogic::apply(&rule, &data), Ok(Value::Bool(true)));

let data = json!({ "foo": 3 });
assert_eq!(jsonlogic::apply(&rule, &data), Ok(Value::Bool(false)));

See the examples directory for more usage examples.

Operations

jsonlogic_rs supports all JsonLogic operations. For detailed informations about all operations and their arguments, head over to Supported Operations on jsonlogic.com.

For Rust usage examples and edge cases have a look at the linked tests for each operator below.

Dependencies

~0.5–1MB
~20K SLoC