Install
Add to your shard.yml:
dependencies:
shiny_json_logic:
github: luismoyano/shiny-json-logic-crystal
Then run:
$ shards install
Usage
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.