Reputation: 85
I am learning jq. I have content as below:
{
"amphorae_links":[
],
"amphorae":[
{
"status":"BOOTING",
"loadbalancer_id":null,
"created_at":"2020-06-23T08:56:56",
"vrrp_id":null,
"id":"6d66935e-6d39-40c9-bb0d-dd6a734dc77b"
},
{
"status":"ALLOCATED",
"loadbalancer_id":"79970c9a-b0ba-4cde-a7e6-16b61641a7b8",
"created_at":"2020-06-25T06:41:56",
"vrrp_id":1,
"id":"872c08ee-9b21-4b26-9550-c2ffb4a1ad59"
}
]
}
I want to have an output like
"ALLOCATED=872c08ee-9b21-4b26-9550-c2ffb4a1ad59,79970c9a-b0ba-4cde-a7e6-16b61641a7b8"
I tried to use below, but I don't know how to remove the line with status as "BOOTING".
.amphorae[] | "\(.status)=\(.id),\(.loadbalancer_id)"
Thanks anyone for the helping.
Upvotes: 0
Views: 74
Reputation: 1776
You have a couple of options:
.amphorae[1] | "\(.status)=\(.id),\(.loadbalancer_id)"
.amphorae | map(select(.status == "ALLOCATED"))[] | "\(.status)=\(.id),\(.loadbalancer_id)"
Upvotes: 2