fujq

0.1.1 • Public • Published

fujq - Javascript-powered command-line JSON processor

jq is great for simple filters, but more complex queries are awkward to write. fujq lets you process JSON documents using Javascript.

For example, given the following JSON document,

[{"id": 1}, {"id": 2}, {"id": 3}]

I can't figure out how to instruct jq to do something like

give me all objects except those with ids 1 or 2.

With fujq it's just javascript:

$ echo '[{"id": 1}, {"id": 2}, {"id": 3}]' |\
>     fujq 'let excl = [1, 2]; return d.filter(i => !excl.includes(i.id))'
[{"id":3}]

How it works

fujq parses stdin as a json document and stores the resulting object in variable d. Then it evals your script, and outputs the returned value as JSON on stdout.

Installing

npm install fujq

Readme

Keywords

none

Package Sidebar

Install

npm i fujq

Weekly Downloads

2

Version

0.1.1

License

MPL-2.0

Unpacked Size

2.05 kB

Total Files

3

Last publish

Collaborators

  • wraugh