jq - Filtering JSON array if does not contains not working jq - Filtering JSON array if does not contains not working json json

jq - Filtering JSON array if does not contains not working


Your query seems a bit overcomplicated for such a trivial task (I didn't debug but you're probably misusing contains there; I suspect it's run for each array element, not just once for the array itself).

Anyways, here is a clean and straightforward approach:

.[] | select(.labels | index("To Do") | not) | "\(.id) -- \(.title) -- \(.labels)"

And avoid UUOC btw.


I'd go with all(_; . != "To Do"):

.[] | select( all(.labels[]; . != "To Do"))|  "\(.id) -- \(.title) -- \(.labels)"