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
🌐
GitHub
gist.github.com › ipbastola › 2c955d8bf2e96f9b1077b15f995bdae3
JQ to filter JSON by value · GitHub
I'm answering my own question. It is possible by piping one select statement into another for an AND operation. Not sure about the OR. You can also use or and and within select. cat my.json | jq -c '.[] | select( ._id == 611 or .author == "John Doe" )'
Discussions

JQ - filter datasets in array based on index value within each dataset of array.
I managed to process it by spliting the log file in small part (one line = one json): ... Thanks. This is a nice trick to remember. ... React hook form: Registering fields within nested arrays while only rendering one child array at a time in form data output preview ... Using JQ to return the index number where an element in an array has a specific value... More on reddit.com
🌐 r/bash
8
3
October 31, 2023
How do I filter the contents of a json array, but keep the parent with jq? - Unix & Linux Stack Exchange
echo $JSON |jq -r '.|select(.Vpcs[].OwnerId!="abc")' But that doesn't seem to filter the data that I want: More on unix.stackexchange.com
🌐 unix.stackexchange.com
January 29, 2020
How do I make remove all the extra spaces while using jq to read raw html into a JSON string
Try jq --rawfile html <( sed 's/(\w)\+/\1/g' ) The syntax <( ) enables you to provide a subprocess where a filename is expected. My sed command is an off-the-cuff attempt to replace repeating occurrences of whitespace with a single instance. You can use any command you want to clean up your html template. More on reddit.com
🌐 r/bash
2
2
August 10, 2023
Using JQ to return the index number where an element in an array has a specific value.
jq '[.Channels[].Channel_Short]|index("ch02")' Settings.json ? More on reddit.com
🌐 r/bash
8
7
July 27, 2023
🌐
jq
jqlang.org › manual
jq 1.8 Manual
The absolute simplest filter is . . This filter takes its input and produces the same value as output. That is, this is the identity operator. Since jq by default pretty-prints all output, a trivial program consisting of nothing but .
🌐
DEV Community
dev.to › anks › using-jq-to-filter-json-data-36c5
Using jq to filter JSON data - DEV Community
October 7, 2022 - To filter ids: $ jq '.[].id' file.json 1 2 $ cat file.json | jq '.[] | .id' 1 2 $ cat file.json | jq '.[].id' 1 2 · To return value of name key when id is 1 · $ jq '.[] | select(.id == 1) | .name' file.json "test1" $ cat file.json | jq '.[] | select(.id == 1) | .name' "test1" To filter ids as json ·
🌐
Reddit
reddit.com › r/bash › jq - filter datasets in array based on index value within each dataset of array.
r/bash on Reddit: JQ - filter datasets in array based on index value within each dataset of array.
October 31, 2023 - I managed to process it by spliting the log file in small part (one line = one json): ... Thanks. This is a nice trick to remember. ... React hook form: Registering fields within nested arrays while only rendering one child array at a time in form data output preview ... Using JQ to return the index number where an element in an array has a specific value...
Find elsewhere
🌐
Zendesk Developer Docs
developer.zendesk.com › documentation › integration-services › developer-guide › jq-cheat-sheet
jq cheat sheet | Zendesk Developer Docs
Important: The expr parameter requires a valid JSON string value. Before using a jq expression in the expr parameter, escape any JSON special characters with a leading backslash (\). For example, use \" to escape double quotes. Disclaimer: Zendesk provides this article for instructional purposes only. Zendesk does not support or guarantee the jq expressions in this article. For complete jq documentation, refer to the jq manual. A jq expression consists one or more filters...
🌐
Earthly
earthly.dev › blog › jq-select
JQ Select Explained: Selecting elements from JSON with Examples - Earthly Blog
July 24, 2023 - Which is the same syntax for an object in a JSON document, except with jq you can use filters as values.4 · The next problem I have is that I want to summarize some this JSON data. Each issue returned by GitHub has a collection of labels:
🌐
DevOps.dev
blog.devops.dev › json-filter-with-jq-f7a7b42218a4
JSON filter with jq. Beginners article to start analyzing… | by Charles Vissol | DevOps.dev
October 14, 2024 - Here the filter walks through 2 keys. debug is the child key of widget. The output shows on value of the debug tag. This is a short article for beginners who wants to ease their JSON analysis without complex tools. One point to know is that jq works very well with large and complex JSON files.
🌐
DEV Community
dev.to › jbranchaud › reduce-a-json-object-to-just-entries-of-a-specific-type-with-jq-2b2o
Reduce a JSON Object to just Entries of a Specific Type with jq - DEV Community
November 29, 2025 - with_entries(foo) is a shorthand for to_entries | map(foo) | from_entries, useful for doing some operation to all keys and values of an object. This can be extended to select for multiple types with a little conditional logic like so: jq '. | with_entries(select((.value | type) == "array" or (.value | type) == "object"))' data.json
🌐
GitHub
github.com › jbranchaud › til › blob › master › jq › filter-out-results-based-on-list-of-values.md
til/jq/filter-out-results-based-on-list-of-values.md at master · jbranchaud/til
With the select function, we can filter the array down to those objects whose IDs are not inside the list of IDs to exclude. jq '.[] | select([.id] | inside["456", "963"] | not)' data.json · Inside that select, we grab the id as a single value array, check if that value is inside our exclude array, and then invert that result.
Author   jbranchaud
🌐
Medium
kannappanchidambaram.medium.com › understanding-jq-a-guide-to-processing-and-filtering-json-data-2af8b5ec84cf
Understanding jq: A Guide to Processing and Filtering JSON Data | by Kannappan Chidambaram | Medium
December 3, 2023 - From this JSON if we need to fetch fields from the data array then the filter we want to use is called array/object value iterator .[]. This filter extracts values from the given array (or object), so the next filter in the pipeline gets applied ...
🌐
DevDocs
devdocs.io › jq
DevDocs — jq documentation
jq 1.7 API documentation with instant search, offline support, keyboard shortcuts, mobile version, and more.
🌐
Medium
medium.com › @varunsonavni › parsing-json-in-command-line-with-jq-basic-filters-and-functions-c7d85d68fc4a
Parsing JSON in command-line with jq: basic filters and functions | by Varun | Medium
March 15, 2022 - We can transform it into a JSON array by wrapping our current long filter with square brackets - an array constructor. Compare the following example with the previous one and spot the difference. Listing 10. Transforming set of JSON objects into a JSON array of objects using [] constructor. $ jq '[.docs[] | {title,author_name: .author_name[0], publish_year: .publish_year[0]} | select(.author_name!=null and .publish_year!=null)]' openlibrary.json [ { "title": "Słownik tajemnych gwar przestępczych", "author_name": "Klemens Stępniak", "publish_year": 1993 }, { "title": "Integracja regionalna i transfer kapitału", "author_name": "Andrzej Stępniak", "publish_year": 1996 }, ...
🌐
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 - Let’s say we want to know what user2‘s value is in this document. To do this, we need a filter that outputs only the value for a specific name. First, we can select the object, and then select by name: ... This is our first proper query with jq.
🌐
Phpfog
phpfog.com › home › blog › how to filter json records by value with jq
How to filter JSON records by value with jq - PHPFog.com
January 29, 2021 - jq offers an easy way to filter JSON records based on field values with the select() function.
🌐
DevTools Daily
devtoolsdaily.com › jq › examples › select-by-attribute-value
JQ Example: select by attribute value
JQ Examples · /select by attribute value · Ask AI · Your JSON content · CheatsheetHelp · Expression ·
🌐
Fig
fig.io › manual › jq
jq <filter> [files...] | Fig
jq · Command-line JSON processor · On this page · Arguments · Options ·