I have the following in a file (which I will call \"myfile\"):
[{
\"id\": 123,
\"name\": \"John\",
\"aux\": [{
\"abc\": \"random\",
It should be:
jq '.[].aux[].def' file.json
.[]
iterates over the outer array, .aux[]
then iterates over the the aux
array of every node and .def
prints their .def
property.
This will output:
"I want this"
If you want to get rid of the double quotes pass -r
(--raw
) to jq
:
jq -r '.[].aux[].def' file.json
Output:
I want this