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 2,128-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, open the playground.

What is JSONLogic?

JSONLogic is a standard for expressing logic rules as JSON. A rule is:

  • Portable: you store it in a database, send it over an API, or embed it in configuration
  • Language-agnostic: the same rule runs on any conforming implementation
  • Readable: a reviewer reads the rule itself, with no host code around it
  • Safe: evaluating a rule runs no code the rule supplies

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 that age > 18 and country == "US".

How the engine works

datalogic-rs works in two phases:

  1. Compilation: the engine parses the rule and compiles it into a reusable Logic. This phase:

    • assigns each built-in operator an OpCode, and each custom operator a slot on the engine
    • evaluates constant subexpressions once
    • builds output templates in templating mode
  2. Evaluation: the engine runs the compiled logic against your data with:

    • OpCode dispatch, with no operator-name lookup at runtime
    • arena-allocated results that can borrow from the input without copying
    • a context stack for iterator bodies (map, filter, reduce)

Every binding exposes this compile-once, evaluate-many pattern; Performance has the numbers.

Before a rule runs, you can check it: Engine::check (check in every binding) reports unknown operators with a “did you mean” suggestion, wrong argument counts and other mistakes, each with a JSON Pointer into the rule (Rule Analysis). The MissingVar::Error setting turns a read of a misspelled data path into a VariableNotFound error instead of null (Configuration), and Engine::operators() lists every operator your build has (API Reference).

Find your language

Each language has its own chapter with install steps, a quick start 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
Any other languageC ABI
React rule-builder UIReact Visual Debugger

How these docs are organized

Next steps