I have a file in s3
which when unzipped has something of this format
{"a": "foo",
"b": "bar",
"c": : "{\"hello\": \"world\"}"}
Now I know I can parse the value of c
by doing jq '.c | fromjson | .hello'
But let's say I want all the values from this json, a, b, and c
. This is the code snippet I currently have:
aws s3 cp s3://somebucket/somekey.gz - | gunzip | jq '[.a, .b]'
How do I incorporate grabbing the value from c
into this expression?
I want all the values from this json, a, b, and c
jq
solution for valid JSON structure:
... | jq '[.a, .b, (.c | fromjson | .[])]'
.[]
- returns all the values of the array/objectThe output:
[
"foo",
"bar",
"world"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With