This
echo '{"a":[{"b":[{"c":"xxx"}]},{"b":[{"c":"yyy"},{"c":"zzz"}]}]}' |
jq '.a[].b | map({"c": .c})'
produces this:
[
{
"c": "xxx"
}
]
[
{
"c": "yyy"
},
{
"c": "zzz"
}
]
How do I get a single output array like:
[
{
"c": "xxx"
},
{
"c": "yyy"
},
{
"c": "zzz"
}
]
$ jq [.[][][][]] <<< "$JSON"
[
{
"c": "xxx"
},
{
"c": "yyy"
},
{
"c": "zzz"
}
]
OR:
$ jq '[.. | select(has("c")?)]' <<< "$JSON"
[
{
"c": "xxx"
},
{
"c": "yyy"
},
{
"c": "zzz"
}
]
您可以使用此:
jq '[{"c":(.a[].b[].c)}]' file.json
这样做:
jq '[ .a[][][] ]'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.