Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 608

How to check if there is a exact match in the jq list

$
0
0

I trying to find a tag that matches a particular image repository in the Docker registry.

curl -X GET http://my-registry-ip-address/v2/ancean-api/tags/list\result: {"name":"ancean-api","tags":["v1.0.0","v19.0.0","v11.1.1"]}

How do I check if the v1.0.0(example) tag exists in the json data output as a result above?


I tried

curl -X GET http://my-registry-ip-address/v2/ancean-api/tags/list | jq '.tags | select(. == v1.0.19)'

jq documentThe jq document attempted to use select but failed.The above command is successful regardless of which tag is used.

curl -X GET http://my-registry-ip-address/v2/ancean-api/tags/list | jq '.tags | .[]' | grep "v1.0.0"

I tried to use it with grep but failed.


Problem Solve

Through pms's answer, I solved the problem with the IN function.

curl -X GET http://my-registry-ip-address/v2/ancean-api/tags/list | jq IN'(.tags[]; "v1.0.0")'

Through the IN method in jq, I was able to get the bool value back when there was a specific value in the json data.enter image description here


Viewing all articles
Browse latest Browse all 608

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>