Install
Add to your Gemfile:
gem 'shiny_json_logic'
Then run:
$ bundle install
Usage
require 'shiny_json_logic'
rule = { ">" => [{ "var" => "age" }, 18] }
data = { "age" => 21 }
ShinyJsonLogic.apply(rule, data)
# => true
# Aliases for easier migration from other gems
JsonLogic.apply(rule, data) # => true
JSONLogic.apply(rule, data) # => true
Try it live
How does it compare?
| Feature | shiny_json_logic | json_logic | json-logic-rb | json_logic_ruby |
|---|---|---|---|---|
| Official tests | 100% | 63.9% | 93.68% | 42.3% |
| Avg. ops/s | 🏆 >100k | ~55k | ~40k | ~45k |
| Last updated | 2026 | 2020 | 2026 | 2024 |
| Ruby 2.x | ✓ | ✓ | ✗ | ✗ |
| Ruby 3.x | ✓ | ✓ | ✓ | ✓ |
| Ruby 4.x | ✓ | ✓ | ✓ | ✓ |
| Handles truthiness correctly | ✓ | ✗ | ✗ | ✗ |
| Zero dependencies | ✓ | ✗ | ✗ | ✗ |
| Actively maintained | ✓ | ✗ | ✓ | ✗ |
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.
Fastest Ruby Implementation
Wins all 18/18 Linux benchmark runs across every Ruby version tested, with margins of +9% to +117% faster. See benchmarks →
Zero Dependencies
No runtime dependencies. Lightweight, predictable, and easy to audit.
Ruby 2.4+ Support
Works on Ruby 2.4 through 4.0, including legacy Rails apps. Other gems require Ruby 3.0+.
Using PHP instead?
Shiny JSON Logic is also available for PHP — same spec compliance, same API.