9 releases

0.2.2 Aug 25, 2022
0.2.1 Apr 26, 2022
0.1.7 Oct 16, 2020
0.1.6 Aug 17, 2020

#43 in Build Utils

Download history 714/week @ 2022-08-15 906/week @ 2022-08-22 1210/week @ 2022-08-29 1428/week @ 2022-09-05 1667/week @ 2022-09-12 1668/week @ 2022-09-19 1353/week @ 2022-09-26 1575/week @ 2022-10-03 1857/week @ 2022-10-10 1562/week @ 2022-10-17 1299/week @ 2022-10-24 1280/week @ 2022-10-31 1206/week @ 2022-11-07 1704/week @ 2022-11-14 376/week @ 2022-11-21 483/week @ 2022-11-28

3,816 downloads per month

MPL-2.0 license

175KB
5K SLoC

jexl-rs CircleCI

JEXL in Rust

  • jexl-eval:
  • jexl-parser:

Releases

Releases are done using cargo release. Check cargo-release for more information

License

This project is licensed under the Mozilla Public License 2.0


lib.rs:

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 of the Evaluator Struct You can use the eval function directly to evaluate standalone statements

For example:

use jexl_eval::Evaluator;
use serde_json::json as value;
let evaluator = Evaluator::new();
assert_eq!(evaluator.eval("'Hello ' + 'World'").unwrap(), value!("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::Evaluator;
use serde_json::json as value;
let context = value!({"a": {"b": 2.0}});
let evaluator = Evaluator::new();
assert_eq!(evaluator.eval_in_context("a.b", context).unwrap(), value!(2.0));

Dependencies

~1.7–2.8MB
~70K SLoC