Output the results of select operation in an array – jq

Yes; wrap the filter in an array 🙂 $ jq ‘[.[] | select(.id == “second”)]’ tmp.json [ { “id”: “second”, “val”: 2 }, { “id”: “second”, “val”: 3 } ] Or, use map/1, which is predefined as [.[] | …]. $ jq ‘map(select(.id == “second”))’ tmp.json [same result] To wrap the results in a bash … Read more

How to do an unpretty print on pretty JSON file in shell >> serial string JSON >> ES _bulk?

You can try the great jq tool for parsing JSON in the shell. To de-pretty print with jq, you can use either method below: cat pretty-printed.json | jq -c . jq -c . pretty-printed.json the -c (or –compact-output) tells it to not pretty print (which is the default). The “.” tells it to return the … Read more

CSV to JSON using jq

In short – yes, except maybe for the one-liner bit. jq is often well-suited to text wrangling, and this is especially true of versions with regex support. With regex support, for example, the trimming required by the given problem statement is trivial. Since jq 1.5rc1 includes regex support and has been available since Jan 1, … Read more