JQL — Rust based JSON Query Language

Robby Boney
Short Bits
Published in
3 min readOct 27, 2021

JQL is a project focused on providing a simple engine for querying data from JSON files. I find this project interesting because JSON files are pervasive in the data field and having tools to visualize, query, parse, and mold the data into the ways we need it in the given moment become really valuable.

Query

The two most basic types of selection are accessing a value of a key (child selection) or accessing a list item (index selection). JQL makes this easy by separating keys with a period. Below are a few common tasks you can perform with JQL.

Filtering

Filtering is another common feature used when navigating data. JQL allows us to filter out keys and embedded objects with the “|” operator.

Additionally we can combine the “|” operator with the “.” to select fields from the filtered result.

Ranges

Property Selection

When selecting an object with multiple fields, JQL uses the curly braces and comma separated keys to choose what fields from the object are returned.

Flatten

Flattening is an operation that take nested data and normalizes it to a single “flattened” list in many cases. JQL gives us tools to do this with the “..” operator.

Performance

Another project for querying JSON is “JQ” which is also a lightweight command-line program. JQL impressively outperforms JQ in a number of operations including nested object flattening, array indexing and property selection.

Install with Cargo!

Cargo is Rust’s package manager and can be used to install packages for a rust project as well as install rust programs by downloading source code and compiling for your system. Crates is Rusts package index (similar to pypi for python) and stats show JQL has seen a fair amount of attention this year.

When installing make sure to run rustup update nightly before you install JQL with cargo install jql. This can often fix many compiler errors.

References

--

--

Robby Boney
Short Bits

Director of Product Development @ Interject Data Systems. I write Software for Science, Data & Enterprise…https://robbyboney.notion.site/