Very close! In your select expression, you have to use a pipe (|) before contains.

This filter produces the expected output.

. - map(select(.Names[] | contains ("data"))) | .[] .Id

The jq Cookbook has an example of the syntax.

Filter objects based on the contents of a key

E.g., I only want objects whose genre key contains "house".

$ json='[{"genre":"deep house"}, {"genre": "progressive house"}, {"genre": "dubstep"}]'
$ echo "$json" | jq -c '.[] | select(.genre | contains("house"))'
{"genre":"deep house"}
{"genre":"progressive house"}

Colin D asks how to preserve the JSON structure of the array, so that the final output is a single JSON array rather than a stream of JSON objects.

The simplest way is to wrap the whole expression in an array constructor:

$ echo "$json" | jq -c '[ .[] | select( .genre | contains("house")) ]'
[{"genre":"deep house"},{"genre":"progressive house"}]

You can also use the map function:

$ echo "$json" | jq -c 'map(select(.genre | contains("house")))'
[{"genre":"deep house"},{"genre":"progressive house"}]

map unpacks the input array, applies the filter to every element, and creates a new array. In other words, map(f) is equivalent to [.[]|f].

Answer from Iain Samuel McLean Elder on Stack Overflow
🌐
jq
jqlang.org › manual
jq 1.8 Manual
To capture all the matches for each input string, use the idiom [ expr ], e.g. [ scan(regex) ]. If the regex contains capturing groups, the filter emits a stream of arrays, each of which contains the captured strings. ... Splits an input string on each regex match. For backwards compatibility, when called with a single argument, split splits on a string, not a regex. ... These provide the same results as their split counterparts, but as a stream instead of an array. ... Emit the string obtained by replacing the first match of regex in the input string with tostring, after interpolation. tostring should be a jq string or a stream of such strings, each of which may contain references to named captures.
🌐
GitHub
github.com › jqlang › jq › issues › 861
Print array element if it contains · Issue #861 · jqlang/jq
July 21, 2015 - I would like to be able to print out elements that have a value inside key that contains ".dar.". I think it would be possible if I was working with numbers in the values but cannot figure out how to do a regex, and using contains just prints true or false. I would basically like to know how to get the following output · { "key1": "lorem ipsum", "key2": "bler dar de" } { "key1": "blurb blurb blurb", "key2": "dar dar dar" } I would picture the command looking similar to this but cannot get anything to work · cat JSONFile.json | jq '.arrayOfStuff | if .[].key2 =~ /.*dar.*/ then .[] end' Anybody know of a way to do this?
Author   miked63017
🌐
Earthly
earthly.dev › blog › jq-select
JQ Select Explained: Selecting elements from JSON with Examples - Earthly Blog
July 24, 2023 - jq contains built-in functions (length,sort,select,map) and pipes (|), and you can compose these together just like you can combine pipes and filters at the command line:
🌐
Zendesk Developer Docs
developer.zendesk.com › documentation › integration-services › developer-guide › jq-cheat-sheet
jq cheat sheet | Zendesk Developer Docs
If the array contains the tag, the expression returns true. Otherwise, the expression returns false. jq expression: .ticket.tags | any(index("enterprise")) Input: { "ticket": { "tags": ["enterprise", "production"] }} Result: true · Combine the select and index filters to compare a flat array to an array of objects.
Find elsewhere
🌐
DevDocs
devdocs.io › jq
DevDocs — jq documentation
jq 1.7 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
🌐
GitHub
github.com › jqlang › jq › issues › 33
filter on "string contains" · Issue #33 · jqlang/jq
October 23, 2012 - Perhaps I'm missing it, but I can't see a way to filter based on a value containing a string. Something like jq 'select(.msg.indexOf('Me") != -1)' Input [ {"msg": "Pick Me!", "date": "2012-10-22 04:42:05"}, {"msg": "Not this one","date":...
Author   billehunt
🌐
iO Flood
ioflood.com › blog › jq-select
The jq 'select' Command | Your Key to JSON Data Filtering
November 16, 2023 - In this example, we’re using jq ‘select’ with two conditions: .city == "New York" and .age > 25. The command will only return JSON objects that meet both conditions. In our case, only John’s data is returned, as he lives in New York and is over 25. You can also combine jq ‘select’ with other jq commands for more advanced data processing.
🌐
Bentasker
snippets.bentasker.co.uk › posts › misc › selecting-subattributes-based-on-substrings.html
Filtering and Selecting Substrings in JSON with jq | snippets.bentasker.co.uk
December 31, 2024 - This snippet describes how to use it filter based on the presence (or absence) of a substring within a JSON object's attribute. It also describes how to use a regular expression to extract that substring with an example of printing to a CSV. Language: MISC · # Filtering based on presence of ...
Published   Dec 31, 2024
Author   Ben Tasker
🌐
Empty Space
siliconheaven.info › jq-queries
Filtering and find with jq
September 17, 2023 - Use jq to reference the brands -> .brands[] Filter that data by using the select operator on the field displayNameState combined with the contains for text searching .brands[] | select( .displayNameState | contains("REVIEW_STATE_NEW") Select the fields into a single field and pipe the output as csv format | [.name, .displayNameState, .iconState, .propertyCount] | @csv ·
🌐
GitHub
gist.github.com › ipbastola › 2c955d8bf2e96f9b1077b15f995bdae3
JQ to filter JSON by value · GitHub
Syntax: cat <filename> | jq -c '.[] | select( .<key> | contains("<value>"))' Example: To get json record having _id equal 611 · cat my.json | jq -c '.[] | select( ._id | contains(611))' Remember: if JSON value has no double quotes (eg. for numeric) to do not supply in filter i.e.
🌐
Red Hat
developers.redhat.com › articles › 2025 › 11 › 20 › how-build-your-dynamic-plug-ins-developer-hub
How to build your dynamic plug-ins for Developer Hub | Red Hat Developer
December 17, 2025 - The dynamic plug-in system allows you to install, configure, and load plug-ins at runtime without changing or rebuilding the application, requiring only a restart. You can load these plug-ins from npm, tarballs, or OCI compliant container images.
🌐
W3Schools
w3schools.com › jquery › jquery_selectors.asp
jQuery Selectors
The jQuery element selector selects elements based on the element name.
🌐
Container Solutions
blog.container-solutions.com › learn-jq-the-hard-way-part-iii-filters
Learn JQ the Hard Way, Part III - Filters
November 15, 2023 - This file contains a simple JSON object with two name-value pairs (user1, and user2 being the names, and alice and bob being their values, respectively). The concept of the filter is central to jq. The filter allows us to select those parts of the JSON document that we might be interested in.
🌐
Luis Cacho
luiscachog.io › garden › jq-select-based-on-value
jq select objects based on a value | Luis Cacho
May 18, 2022 - jq '.DATA[] | select(.DOMAIN == ("domain2","domain3")) | .DOMAINID,.DOMAIN' 22222 "slave" 33333 "slave" # or jq '.DATA[] | select(.DOMAIN | IN("domain2", "domain3")) | .DOMAINID,.DOMAIN' 22222 "slave" 33333 "slave"
🌐
Bartificer
pbs.bartificer.net › pbs158
PBS 158: More Queries (jq)
December 20, 2023 - When the input being processed and the argument are strings, contains will return true if the input string contains the entire argument string (contiguously), otherwise it will return false: echo '"I love waffles"' | jq 'contains("waffles")' ...
🌐
Kubernetes
kubernetes.io › docs › reference › kubectl › quick-reference
kubectl Quick Reference | Kubernetes
4 weeks ago - kubectl get pods --all-namespaces -o jsonpath='{range .items[*].status.initContainerStatuses[*]}{.containerID}{"\n"}{end}' | cut -d/ -f3 # List Events sorted by timestamp kubectl get events --sort-by=.metadata.creationTimestamp # List all warning events kubectl events --types=Warning # Compares the current state of the cluster against the state that the cluster would be in if the manifest was applied. kubectl diff -f ./my-manifest.yaml # Produce a period-delimited tree of all keys returned for nodes # Helpful when locating a key within a complex nested JSON structure kubectl get nodes -o json | jq -c 'paths|join(".")' # Produce a period-delimited tree of all keys returned for pods, etc kubectl get pods -o json | jq -c 'paths|join(".")' # Produce ENV for all pods, assuming you have a default container for the pods, default namespace and the `env` command is supported.