JSONLogic Shiny JSON Logic

shiny_json_logic

The most compliant Crystal implementation of JSON Logic. 100% of official tests. Crystal 1.0+. Zero dependencies.

601/601 official tests
100% spec compliant
Crystal 1.0+ supported

Install

Add to your shard.yml:

shard.yml
dependencies:
  shiny_json_logic:
    github: luismoyano/shiny-json-logic-crystal

Then run:

Terminal
$ shards install

Usage

app.cr
require "shiny_json_logic"

rule = JSON.parse(%({">" : [{"var": "age"}, 18]}))
data = JSON.parse(%({"age": 21}))

ShinyJsonLogic.apply(rule, data)
# => true

# Drop-in aliases are registered automatically
JsonLogic.apply(rule, data)   # also works
JSONLogic.apply(rule, data)   # also works

Why shiny_json_logic?

100% Spec Compliant

Passes all 601 official JSON Logic tests from the json-logic community. No edge cases swept under the rug.

Native Crystal Performance

Compiled, type-safe, zero overhead. Evaluates JSON Logic rules at native speed with no runtime dependencies.

Drop-in Aliases

Registers JsonLogic and JSONLogic as aliases automatically. Familiar API if you're coming from the Ruby or PHP ports.

Actively Maintained

Built and maintained by contributors to the JSON Logic specification. Issues are addressed. PRs are welcome.

Also available for Ruby and PHP

Same spec compliance, same API across all three languages.

See how fast it is

Compare Crystal against Ruby and PHP in our live benchmark suite.

View Benchmarks →