问题
I have an array of objects similar to the following:
[
{
"id": "one",
"tags": {
"my.key": "true"
}
},
{
"id": "two",
}
]
How can I select all "id" values for each object containing a tag where "my.key" is "true"?
回答1:
You can use a select
with .tags["my.key"] == "true"
and get only the id
field :
jq '.[] | select(.tags["my.key"] == "true") | .id' data.json
来源:https://stackoverflow.com/questions/41369982/how-to-select-a-json-object-where-a-child-value-array-contains-a-certain-propery