Skip to content
master
Go to file
Code

Latest commit

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

About

JSONiq Implementation that compiles to JavaScript

Resources

License

Releases

No releases published
You can’t perform that action at this time.