Jmespath Implementation for Crystal

Hey everyone,

I was recently working on a Crystal project and needed to query json data using jmespath. However, I couldn’t find an existing implementation for Crystal, so I decided to build one

You can check it out the github repo

It works the same to jmespath implementations in other languages. Here are some examples:

require "jmespath"

# Basic object access
data = %({"foo": {"bar": "baz"}})
JMESPath.search("foo.bar", data) # => "baz"

# Array operations
data = %({"people": [{"name": "bob"}, {"name": "alice"}]})
JMESPath.search("people[1].name", data) # => "alice"

# List projections
data = %({"people": [{"age": 20}, {"age": 25}, {"age": 30}]})
JMESPath.search("people[*].age", data) # => [20, 25, 30]

This is still a work in progress, and I’m looking for feedback on performance, API design, and general improvements. Contributions are very welcome!

7 Likes

This is really cool!

I’ve added it to crystaldoc.info for auto-generated API documentation: jmespath main

3 Likes

that’s awesome thanks!