Fast, embeddable, cross-runtime JSON-Logic evaluation.
- Rust core — zero-overhead evaluation with strong type safety
- Python bindings — native speed via PyO3, no subprocess overhead
- WASM bindings — run in browsers and Node.js, same deterministic results
- Parallel batch — Rayon-powered multi-threaded evaluation on native platforms
- Deterministic — same rule + same data = same result, always
[dependencies]
jsonlogic-fast = "0.1"pip install jsonlogic-fastuse jsonlogic_fast::evaluate;
let rule = r#"{"if":[{">":[{"var":"score"},700]},"approve","review"]}"#;
let context = r#"{"score":742}"#;
let result = evaluate(rule, context).unwrap();
// result == json!("approve")import json
import jsonlogic_fast
rule = json.dumps({">": [{"var": "score"}, 700]})
ctx = json.dumps({"score": 742})
result = jsonlogic_fast.evaluate(rule, ctx) # Trueimport { evaluate_wasm } from "jsonlogic-fast-wasm";
const result = evaluate_wasm(
'{">":[{"var":"score"},700]}',
'{"score":742}'
);
// result == "true"| Function | Return | Description |
|---|---|---|
evaluate |
Value |
Evaluate rule against context |
evaluate_numeric |
f64 |
Evaluate and coerce to number |
evaluate_batch |
Vec<Value> |
Parallel evaluation of N contexts |
evaluate_batch_detailed |
Vec<EvaluationResult> |
Batch with per-item error info |
evaluate_batch_numeric |
Vec<f64> |
Batch numeric with fail-safe zeros |
evaluate_batch_numeric_detailed |
Vec<NumericEvaluationResult> |
Batch numeric with errors |
validate_rule |
bool |
Preflight rule validation |
serialize |
String |
JSON serialization |
get_core_info |
Value |
Engine metadata |
make bench # full Criterion benchmarks
make bench-quick # reduced sample for quick feedbackIncluded benchmarks:
- Single numeric evaluation
- Single generic (conditional) evaluation
- Batch numeric evaluation (10K contexts)
jsonlogic-fast wraps the jsonlogic-rs crate
in a Rust core compiled to native code, exposed to Python via PyO3 and to browsers via
WASM. The "fast" comes from:
- Zero Python overhead — rule parsing, evaluation, and serialization happen entirely in Rust.
- Parallel batch evaluation — Rayon distributes N contexts across all available CPU cores.
- Single parse, many evaluations —
evaluate_batchparses the rule once and reuses it.
| Scenario | jsonlogic-fast | json-logic-qubit | Speedup |
|---|---|---|---|
| Simple comparison | 0.001 ms | 0.004 ms | 3.6x |
| Conditional (nested if) | 0.003 ms | 0.011 ms | 4.0x |
| Complex (logic + arithmetic + var paths) | 0.005 ms | 0.025 ms | 4.7x |
| Batch 10K contexts | 5.3 ms | 51.4 ms (sequential loop) | 9.7x |
Run
make bench-pythonto reproduce. Runmake benchfor Criterion (Rust) benchmarks.
make bench # full Criterion benchmarks (HTML reports in target/criterion/)
make bench-quick # reduced sample for quick feedbackmake test # core Rust tests (11)
make test-python # Python e2e tests (29)
make test-wasm # WASM runtime tests (15)
make ci-local # full quality gateLicensed under either of
at your option.