jq extracting properties to arrays from json row line
For example if we have a file that contains JSON object like
1
{"a": 1, "b":{"c": 11}
2
{"a": 2, "b":{"c": 22}}
3
{"a": 3, "b":{"c": 33}}
Copied!
And you want to construct something like
1
["1", "11"]
2
["2", "22"]
3
["3", "33"]
Copied!
You can do that with jq
1
$ cat filename.json | jq -c '[.a, .b.c]'
Copied!
this is particularly usefull to grep something from JSON log
Copy link