I have a JSON output as follows:
{
"example": {
"sub-example": [
{
"name": "123-345",
"tag" : 100
},
{
"name": "234-456",
"tag" : 100
},
{
"name": "4a7-a07a5",
"tag" : 100
}
]
}
}
I want to extract the values of the three "name" fields and store it in three variables.
I tried cat json_file | jq '.["example.sub-example.name"]'
to extract the value of the "name" field but that doesn't work.
Can anyone tell me how to achieve this using jq (or some other method)?