{ "count": 3, "next": "", "previous": "", "list": [{ "id": "X1", "name": "STAGING", "description": null, "context": "STAGING", "version": "1.0.0", "provider": "user0", "status": "PUBLISHED", "thumbnailUri": null }, { "id": "X2", "name": "STAGING", "description": null, "context": "STAGING", "version": "2.0.0", "provider": "user1", "status": "PUBLISHED", "thumbnailUri": null }, { "id": "X3", "name": "STAGING", "description": null, "context": "STAGING", "version": "3.0.0", "provider": "user2", "status": "CREATED", "thumbnailUri": null }], "pagination": { "total": 3, "offset": 0, "limit": 25 } }
above is my json - looking for solution where i could loop and get "id" for a given "Version"
for suppose the while i pass argument "Version" = 3.0.0 expecting the output to be as "X3"( which is the key value of "id"
and the json is output from a curl.
this is what i have tried but no error's x= curl(); - which gives me above json as output!
echo "$x" | jq -r 'map(select(any(.version[]; contains("3.0.0"))|not)|.id)[]'
and i see error below:
jq: error (at :1): Cannot index number with string "version"