Top "Jq" questions

jq is a sed-like tool for JSON data – you can use it to slice, filter, map, and transform structured data with the same ease that sed, awk, grep and friends lets you play with text.

How do I sum the values in an array of maps in jq?

Given a JSON stream of the following form: { "a": 10, "b": 11 } { "a": 20, "b": 21 } { "a": 30, "b": 31 } I would like to sum the …

json sum key jq
jq: selecting a subset of keys from an object

Given an input json string of keys from an array, return an object with only the entries that had keys …

json select key subset jq
How to install jq on amazon EC2 instance

I am trying to install jq JSON parser on amazon instance, unfortunately, i'm not able to install it can someone …

linux jq amazon-linux
Deleting multiple keys at once with jq

I need to delete multiple keys at once from some JSON (using jq), and I'm trying to learn if there …

jq
How to convert a string to an integer in a JSON file using jq?

I use jq to transform a complex json object into a tinier one. My query is: jq 'to_entries[]| {companyId: (.…

json casting jq
CSV to JSON using jq

If you have a csv dataset like this: name, age, gender john, 20, male jane, 30, female bob, 25, male Can you get …

json csv jq
jq - How to iterate through keys of different names

I've got JSON that looks like this { "keyword1": { "identifier1": 16 }, "keyword2": { "identifier2": 16 } } and I need to loop through the keywords to …

json key iteration jq
Exclude column from jq json output

I would like to get rid of the timestamp field here using jq JSON processor. [ { "timestamp": 1448369447295, "group": "employees", "uid": "elgalu" }, { "…

json jq
How to filter an array of JSON objects with jq?

I have the following JSON input: { "zk_kafka": [ { "InstanceType": "t2.medium", "zkMemory": "16", "kafkaMemory": "8" }, { "InstanceType": "t2.small", "zkMemory": "8", "kafkaMemory": "4" } ], "es_hdfs": [ { "…

json jq
jq - How do I print a parent value of an object when I am already deep into the object's children?

Say I have the following JSON, stored in my variable jsonVariable. { "id": 1, "details": { "username": "jamesbrown", "name": "James Brown" } } I parse …

json jq