JSPM

  • Created
  • Published
  • Downloads 66628
  • Score
    100M100P100Q153845F
  • License MIT

Run jq in node

Package Exports

  • node-jq

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-jq) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-jq logo

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'
// or
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)
    // something with the output
  })
  .catch((err) => {
    console.error(err)
    // something with the error
  })

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