Home

Awesome

npm test

jfq

JSONata on the command line.

This was inspired by the excellent jq utility, and uses JSONata rather than the jq language.

Installation

npm install --global jfq

Usage

jfq [options] [<JSONata query>] [<files>]

It is good practice to put the JSONata query in single quotes, so that the shell does not attempt to interpret it.

The output will formatted as JSON, unless it's an array of simple objects (e.g. string, number) when the output is flattened to a series of lines, so that it can be piped to another program such as xargs.

Options

Examples

jfq 'dependencies.jsonata' package.json

# ^1.5.0
curl -s \
  https://api.npmjs.org/downloads/range/last-year/jsonata \
  | jfq 'downloads{$substring(day, 0, 7): $sum(downloads)}'

# {
#  "2017-02": 36216,
#  "2017-03": 46460,
#  "2017-04": 40336,
#  ...
# }