2

I'm looking for a tool like jq but which is easier to use for normal use cases (but less powerful), before I write one myself.

Context

I often find myself interacting with json stream, it is very natural for a program to produce a stream of JSON which other programs can filter.

jq is wonderful for complicated queries, and I know it well enough to write most of the queries I use without reference to documentation. However, for simpler things the amount of boiler plate can be a little excessive. For example look at

program | jq 'select(.field | test("match", i))'

and compare it to

program | grep -i match

Desired tool

Is there any tool which is more of a middle ground: less power but less boiler-plate.

Maybe something like:

program | json-filter --field match --filter key1,key2,key3

2 Answers 2

3

Take a look at fx 🔥

It's plain JavaScript cli JSON manipulating tool (alternative to jq) with standalone binary.

program | fx 'input => input.filter(x => ...).map(x => {a: a.x})'
0

Sometimes gron (github, >8700 stars) might help to make JSON greppable .

Then the pipeline is < my.json gron | grep -v "something-to-remove" | gron -u

The readme has much better examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.