Skip to content

encypherai/json-formula-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json-formula-rs

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.

Usage

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(())
}

Testing

The official json-formula JSON test fixtures are stored under tests/fixtures and are executed via the Rust test harness:

cargo test

Official Suite

To run just the official json-formula fixtures:

cargo test --test official_suite

Note: precedence expectations in tests/fixtures/precedence.json are validated by the parser test helpers; failures will surface as part of the test run.

Development

# Run the full test suite
cargo test -- --nocapture

# Run just the official fixtures
cargo test --test official_suite

Contributing

  1. Keep changes focused and add tests for new behavior when possible.
  2. Run cargo test before opening a PR.
  3. Update README.md and THIRD_PARTY_NOTICES.md if you add new dependencies or fixtures.

License

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.

About

Rust implementation of the json-formula specification

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Rust 100.0%