Native Rust implementation of the Adobe json-formula specification.
The library parses and evaluates json-formula expressions directly against serde_json::Value
data, matching the behavior of the official reference implementation.
use json_formula_rs::JsonFormula;
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let engine = JsonFormula::new();
let data = json!({ "items": [{ "price": 3.5 }, { "price": 2.0 }] });
let result = engine.search("sum(items[*].price)", &data, None, Some("en-US"))?;
println!("Result: {}", result);
Ok(())
}The official json-formula JSON test fixtures are stored under tests/fixtures and are executed
via the Rust test harness:
cargo testTo run just the official json-formula fixtures:
cargo test --test official_suiteNote: precedence expectations in tests/fixtures/precedence.json are validated by the parser test
helpers; failures will surface as part of the test run.
# Run the full test suite
cargo test -- --nocapture
# Run just the official fixtures
cargo test --test official_suite- Keep changes focused and add tests for new behavior when possible.
- Run
cargo testbefore opening a PR. - Update
README.mdandTHIRD_PARTY_NOTICES.mdif you add new dependencies or fixtures.
This project is licensed under the Apache License, Version 2.0. See LICENSE for the full text. It includes test fixtures derived from the Adobe json-formula project; see THIRD_PARTY_NOTICES.md for details.