[−][src]Function jsonlogic::apply
pub fn apply(json_logic: &Value, data: &Value) -> Result<Value, String>
Applies the given JsonLogic rule to the specified data.
If the rule does not use any variables, you may pass &Value::Null
as the second argument.
Example
use serde_json::{json, Value}; let rule = json!({"===": [2, {"var": "foo"}]}); assert_eq!(jsonlogic::apply(&rule, &json!({ "foo": 2 })), Ok(Value::Bool(true))); assert_eq!(jsonlogic::apply(&rule, &json!({ "foo": 3 })), Ok(Value::Bool(false)));