Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wcandillon/jsoniq
JSONiq Implementation that compiles to JavaScript
https://github.com/wcandillon/jsoniq
Last synced: about 1 month ago
JSON representation
JSONiq Implementation that compiles to JavaScript
- Host: GitHub
- URL: https://github.com/wcandillon/jsoniq
- Owner: wcandillon
- License: apache-2.0
- Archived: true
- Created: 2013-03-16T00:27:05.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-02-24T12:21:59.000Z (almost 3 years ago)
- Last Synced: 2024-04-29T20:22:06.054Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 4.68 MB
- Stars: 64
- Watchers: 4
- Forks: 7
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - wcandillon/jsoniq - JSONiq Implementation that compiles to JavaScript (others)
README
# The JSON Query Language
**This project was an experiment and should be used under any circumstances**
[![Circle CI](https://circleci.com/gh/wcandillon/jsoniq/tree/master.svg?style=svg)](https://circleci.com/gh/wcandillon/jsoniq/tree/master) [![NPM version](http://img.shields.io/npm/v/jsoniq.svg?style=flat)](http://badge.fury.io/js/jsoniq)
Compiles JSONiq queries to Javascript.
```bash
$ 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
```bash
$ npm install jsoniq -g
```Compiled queries need to access the runtime library therefore the jsoniq package needs to be installed as well.
```bash
$ npm install jsoniq --save
$ jsoniq compile test.jq
$ node test.js
```
## Usage
To compile a query to JavaScript:
```bash
$ 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
```bash
$ jsoniq run query.jq
```To print the query AST:
```bash
$ jsoniq ast query.jq
```To print the query plan:
```bash
$ jsoniq plan query.jq
```