Home

Awesome

jqjs is a JavaScript implementation of the jq query language. It implements the core language features in pure JavaScript.

The main entry point to jqjs is the compile function, which turns a jq program string into a generator function:

import jq from './jq.js'
let filter = jq.compile(".x[].y")
for (let v of filter({x:[{y:2}, {y:4}]}) { ... }

The module also has a prettyPrint function for rendering an object to text.

Features

jqjs supports most of the core jq language features, but lacks functions and some of the advanced functionality. It also uses JavaScript strings as backing, so does not have jq proper's Unicode support.

Performance

Not great.

The intention is to be semantically correct first and to have clear code second. Performance improvements sit after that, if at all. Executing a program may reƫvaluate parts of it or traverse the object multiple times where that makes things simpler, and internally evaluation happens by tree-walking the input syntax.

Demonstration

demo.html is a live demo of how to use jqjs that lets you enter a jq program and an input JSON value and see the output JSON values it produces.