jsonlogic 0.5.1

A JsonLogic implementation in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use serde_json::{json, Value};

use super::{logic, Data, Expression};

pub fn compute(args: &[Expression], data: &Data) -> Value {
    let a = args
        .get(0)
        .map(|arg| arg.compute(data))
        .unwrap_or(json!(null));
    let b = args
        .get(1)
        .map(|arg| arg.compute(data))
        .unwrap_or(json!(null));

    Value::Bool(logic::is_strict_equal(&a, &b))
}