JSONiq Implementation that compiles to JavaScript
TypeScript HTML XQuery JSONiq JavaScript
Latest commit 7cc9c03 Dec 30, 2015 @wcandillon Update tests.js
Permalink
Failed to load latest commit information.
bin πŸ†• CLI May 9, 2015
grammars πŸ”§ May 15, 2015
lib πŸ”§ Dec 5, 2015
tasks Update tests.js Dec 30, 2015
tests πŸ”§ Dec 5, 2015
.gitignore πŸ’„ Apr 26, 2015
.jshintrc bootstrap Jul 21, 2014
.npmignore πŸ”§ Dec 5, 2015
LICENSE Add LICENSE file Aug 22, 2014
README.md πŸ”§ Dec 5, 2015
circle.yml Update circle.yml Dec 24, 2015
gulpfile.js πŸ”§ Nov 28, 2015
package.json πŸ”§ Dec 5, 2015
tsd.json πŸ’š Dec 2, 2015
tslint.json Typescript integration Aug 4, 2014

README.md

The JSON Query Language

Circle CI NPM version

Compiles JSONiq queries to Javascript.

$ cat query.jq
for $x in (4,1,2,3)
for $y in (4,1,2,3)
order by $x ascending, $y descending
return { x: $x, y: $y }
$ jsoniq compile query.jq
$ node query.js
{ x: 1, y: 4 }
{ x: 1, y: 3 }
{ x: 1, y: 2 }
{ x: 1, y: 1 }
{ x: 2, y: 4 }
{ x: 2, y: 3 }
...

Install

$ npm install jsoniq -g

Compiled queries need to access the runtime library therefore the jsoniq package needs to be installed as well.

$ npm install jsoniq --save
$ jsoniq compile test.jq
$ node test.js

Usage

To compile a query to JavaScript:

$ cat query.jq
for $x in (4,1,2,3)
for $y in (4,1,2,3)
order by $x ascending, $y descending
return { x: $x, y: $y }
$ jsoniq compile query.jq
$ node query.js
{ x: 1, y: 4 }
{ x: 1, y: 3 }
{ x: 1, y: 2 }
{ x: 1, y: 1 }
{ x: 2, y: 4 }
{ x: 2, y: 3 }
...

Or to run the query directly

$ jsoniq run query.jq

To print the query AST:

$ jsoniq ast query.jq

To print the query plan:

$ jsoniq plan query.jq