Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

datalogic-rs is a JSONLogic rules engine: one Rust core with official bindings for Rust, Node.js, the browser (WASM), Python, Go, Java, .NET, and PHP, plus a React visual debugger. Rules are plain JSON; the same rule evaluates with identical semantics in every runtime, verified by a 1,565-case conformance battery that runs against the same core every binding ships.

This site is the reference documentation. For the project pitch, benchmarks, and package matrix, see the GitHub repository; to try rules in your browser right now, open the playground.

What is JSONLogic?

JSONLogic is a standard for expressing logic rules as JSON. This makes it:

  • Portable: Rules can be stored in databases, sent over APIs, or embedded in configuration
  • Language-agnostic: The same rules work across different implementations
  • Human-readable: Rules are easier to understand than arbitrary code
  • Safe: Rules can be evaluated without arbitrary code execution

A JSONLogic rule is a JSON object where the key is the operator name and the value is an array of arguments:

{"operator": [arg1, arg2, ...]}

For example:

{"and": [
  {">": [{"var": "age"}, 18]},
  {"==": [{"var": "country"}, "US"]}
]}

This rule checks if age > 18 AND country == "US".

How the engine works

datalogic-rs uses a two-phase approach:

  1. Compilation: Your JSON logic is parsed and compiled into a reusable Logic. This phase:

    • Assigns OpCodes to built-in operators for fast dispatch
    • Pre-evaluates constant expressions
    • Analyzes structure for templating mode
  2. Evaluation: The compiled logic is evaluated against your data with:

    • Direct OpCode dispatch (no string lookups at runtime)
    • Arena-allocated results that can borrow zero-copy from the input
    • A context stack for nested operations (map, filter, reduce)

Compile once, evaluate many: that is the pattern every binding exposes, and the reason evaluation runs in nanoseconds.

Find your language

Every language has a first-class chapter with install, quickstart, and the API surface:

Your stackStart here
RustRust (native crate)
Node.js servicesNode.js (native)
Browser, edge, Deno, BunJavaScript (WASM)
PythonPython
GoGo
Java, Kotlin, ScalaJava / Kotlin (JVM)
.NET (C#, F#).NET
PHPPHP
Another language entirelyC ABI
React rule-builder UIReact Visual Debugger

How these docs are organized

Next steps