This is a follow up question from this question that got contributed by another person. I have following output from a webserver:
{
"status":"OK",
"result":{
"string1":{
"variable":0
},
"string2":[
{
"id":"XXXXX:XXXXX",
"tier":"normal",
"latitude":"01.XXXXX",
"longitude":"02.XXXXX"
},
{
"id":"XXXXX:XXXXX",
"tier":"normal",
"latitude":"01.XXXXX",
"longitude":"02.XXXXX"
},
{
"id":"XXXXX:XXXXX",
"tier":"special",
"latitude":"01.XXXXX",
"longitude":"02.XXXXX"
},
{
"id":"XXXXX:XXXXX",
"tier":"normal",
"latitude":"01.XXXXX",
"longitude":"02.XXXXX"
}
]
}
}
i'm extracting the ids with jq -r '.result.string2[].id' responses.json right now and safing them as a responses.json file; this works perfectly fine.
However, my question is, how do i set the condition so jq will only output me the id's if tier: "special"? I tried to solve it with the answer in this thread, alias these two:
jq -r '.result.string2[] | select(.tier == "special") | .id'responses.json
jq -r '.result.string2[] | select(.tier == "special") | .id' responses.json
This doesn't seem to work in my Windows-PowerShell. It gives me the following error message:
jq: error: special/0 is not defined at <top-level>, line 1:
.result.string2[] | select(.tier == special) | .id jq: 1 compile error
Thanks for answering!
specialin the question appears quoted. I don't know Powershell at all. Does it do strange things to quoted strings?