node-jq is a wrapper for jq - a lightweight and flexible command-line JSON processor.
Installation
npm install node-jq --save
jq
is not required. If it doesn't exist, the latest version of jq
is installed in the node_modules/.bin/
folder.
Usage
import { run } from 'node-jq'
const { run } = require('node-jq')
const filter = '. | map(select(.foo > 10))'
const jsonPath = '/path/to/json'
const options = {}
run(filter, jsonPath, options)
.then((output) => {
console.log(output)
})
.catch((err) => {
console.error(err)
})
Options
Option | Type | Default | Values | Description |
---|
input | String | 'file' | 'file', 'json', 'string' | Specify the type of input |
output | String | 'pretty' | 'json', 'string', 'pretty' | Specify the type of output |
How to use this?
We use it ourselves in an Atom plugin. Check it out: atom-jq
License
MIT