Note that, just like jq, when checking if an array of strings contains another, this will use contains and not equals to check each string. For all sort of filtering tasks, you will almost always want to use the select builtin; A string b is contained in a string a if b is a substring of a.
Use jq to update property of object that contains other property with specific value When attempting to run the jq command, it has this error: A working script for your use case would be as.
For strings, it will return true if the string is a substring. It appears that despite the variable containing the qoutes, the space in the variable is stopping the query. An array b is contained in an array a. # get name of id 1 $ cat file.json | jq '.results[] | select(.id == 1) | {name}' # get result with multiple filters $ cat file.json | jq '.results[] | select((.id == 1) and (.name=a))' # filter with.
The filter contains(b) will produce true if b is completely contained within the input. And for text matching tasks, you may want to use contains. If json value has no double quotes (eg.</p> To get json record having _id equal 611.