[−][src]Crate jexl_eval
A JEXL evaluator written in Rust This crate depends on a JEXL parser crate that handles all the parsing and is a part of the same workspace. JEXL is an expression language used by Mozilla, you can find more information here: https://github.com/mozilla/mozjexl
How to use
The access point for this crate is the eval
functions
You can use the eval
function directly to evaluate standalone statements
For example:
use jexl_eval::eval; assert_eq!(eval("'Hello ' + 'World'").unwrap(), "Hello World");
You can also run the statements against a context using the eval_in_context
function
The context can be any type that implements the serde::Serializable
trait
and the function will return errors if the statement doesn't match the context
For example:
use jexl_eval::eval_in_context; use serde_json::json as value; let context = value!({"a": {"b": 2.0}}); assert_eq!(eval_in_context("a.b", context).unwrap(), value!(2.0));
Modules
error |
Functions
eval | |
eval_in_context |