jsonlogic

Crates.iojsonlogic
lib.rsjsonlogic
version0.5.1
sourcesrc
created_at2019-11-26 11:47:18.468657
updated_at2020-03-05 22:09:50.947886
descriptionA JsonLogic implementation in Rust
homepage
repositoryhttps://github.com/marvindv/jsonlogic_rs
max_upload_size
id184464
size145,003
Marvin Davieds (marvindv)

documentation

README

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.

Commit count: 87

cargo fmt