Given then following JSON
[
{
"id": "1",
"name": "sausage",
"value": 100
},
{
"id": "2",
"name": "spam",
"value": 200
},
{
"id": "3",
"name": "eggs",
"value": 300
}
]
I can select a single record with id=3
with:
jq '.[] | select(.id=="3") | .name,.value' data.json
### > "sausage"
### > "100"
But how to select several id
's, i.e. the items with id in (1,2)
?
## this is something I wish I could do
jq '.[] | select(.id in ("1", "2") | .name,.value' data.json
I tried:
jq '.[] | select(.id=="1") or select(.id=="2") | .name,.value' data.json
but this results in an error.