Skip to content

A fast, type-safe Rust implementation of JSONLogic for evaluating logical rules as JSON. Perfect for business rules engines and dynamic filtering in Rust applications.

License

Notifications You must be signed in to change notification settings

GoPlasmatic/datalogic-rs

Repository files navigation

Plasmatic Logo

datalogic-rs

A fast, production-ready Rust engine for JSONLogic.

License: Apache 2.0 Rust Crates.io Documentation npm


Quick Example

use datalogic_rs::DataLogic;
use serde_json::json;

let engine = DataLogic::new();
let logic = json!({ ">": [{ "var": "age" }, 18] });
let compiled = engine.compile(&logic).unwrap();

let result = engine.evaluate_owned(&compiled, json!({ "age": 21 })).unwrap();
assert_eq!(result, json!(true));

Packages

Package Description Install
datalogic-rs Rust library cargo add datalogic-rs
@goplasmatic/datalogic WASM/JavaScript npm i @goplasmatic/datalogic
@goplasmatic/datalogic-ui React visual debugger npm i @goplasmatic/datalogic-ui

Resources

Online Debugger

JSONLogic Online Debugger Demo

Try the JSONLogic Online Debugger to interactively test your rules

Key Features

  • Thread-Safe - Compile once, evaluate anywhere with zero-copy Arc sharing
  • Fully Compliant - Passes the official JSONLogic test suite
  • 59 Built-in Operators - Including datetime, error handling, and extended string/array operations
  • Extensible - Add custom operators with a simple trait
  • Configurable - Customizable NaN handling, division by zero, and truthiness behavior
  • Templating Mode - Preserve object structures for dynamic JSON generation
  • Multi-Platform - Rust, WASM (browser/Node.js), with visual React debugger and editor

JavaScript / TypeScript

import init, { evaluate } from '@goplasmatic/datalogic';

await init();

const result = evaluate(
  '{">=": [{"var": "age"}, 18]}',
  '{"age": 21}',
  false
);
console.log(JSON.parse(result)); // true

React Visual Debugger

import { DataLogicEditor } from '@goplasmatic/datalogic-ui';

<DataLogicEditor
  value={{ "and": [{ ">": [{ "var": "age" }, 18] }, { "var": "active" }] }}
  data={{ age: 25, active: true }}
/>

About Plasmatic

Created by Plasmatic, building open-source tools for financial infrastructure and data processing.

License

Licensed under Apache 2.0. See LICENSE for details.

About

A fast, type-safe Rust implementation of JSONLogic for evaluating logical rules as JSON. Perfect for business rules engines and dynamic filtering in Rust applications.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •