From the docs:

jq '.[] | select(.id == "second")' 

Input [{"id": "first", "val": 1}, {"id": "second", "val": 2}]

Output {"id": "second", "val": 2}

I think you can do something like this:

jq '.theList[] | select(.id == 2 or .id == 4)' array.json
Answer from André Senra on Stack Overflow
🌐
jQuery
api.jquery.com › filter
.filter() | jQuery API Documentation
Given a jQuery object that represents a set of DOM elements, the .filter() method constructs a new jQuery object from a subset of the matching elements.
.on()
A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element. ... Data to be passed to the handler in event.data when an event occurs. The .on() method attaches event handlers to the currently selected set of elements in the jQuery ...
.each()
The .each() method is designed to make DOM looping constructs concise and less error-prone. When called it iterates over the DOM elements that are part of the jQuery object. Each time the callback runs, it is passed the current loop iteration, beginning from 0.
Click event
Properties of the Global jQuery Object · Removed · Selectors · Attribute · Basic · Basic Filter · Child Filter · Content Filter · Form · Hierarchy · jQuery Extensions · Visibility Filter · Traversing · Filtering · Miscellaneous Traversing · Tree Traversal ·
.append()
Similar to other content-adding methods such as .prepend() and .before(), .append() also supports passing in multiple arguments as input. Supported input includes DOM elements, jQuery objects, HTML strings, and arrays of DOM elements.
🌐
DEV Community
dev.to › anks › using-jq-to-filter-json-data-36c5
Using jq to filter JSON data - DEV Community
October 7, 2022 - [] [] - Select array, [n] - Select nth element in the array, [.key1, .key2, ..] - Create new json object · {} {key1: .key1, key2: .key2, ..} or {key1, key2, ..} - Create new json object ... $ jq '.[] | select(.id == 1) | .name' file.json "test1" $ cat file.json | jq '.[] | select(.id == 1) | .name' "test1"
Discussions

shell - Get an array containing partially matching search word from a json array with jq - Unix & Linux Stack Exchange
Given the following json data and "a" as a partially matching search word, how can I get an array ["a", "b", "c"], ["abc", "e", "f&q... More on unix.stackexchange.com
🌐 unix.stackexchange.com
json - jq: how to filter an array of objects based on values in an inner array? - Stack Overflow
I'm trying to construct a filter with jq that returns all objects with Ids that do not contain "data" in the inner Names array, with the output being newline-separated. More on stackoverflow.com
🌐 stackoverflow.com
Creating an array from objects?
First of all, kudos on such an excellent library...I've used jq for basic CLI tasks and have only recently delved into its more advanced functions, and am continually amazed at how things just ... More on github.com
🌐 github.com
7
January 29, 2015
jq: Filter arrays inside an object
Close. You would have needed to write: jq '.phones | with_entries(select(.value | arrays))' phones.json if you wanted to use with_entries like that. But: jq '.phones | pick(.[] | arrays)' phones.json is simpler. More on reddit.com
🌐 r/commandline
3
1
May 10, 2025
🌐
Missing Semester
missing.csail.mit.edu › 2026 › course-shell
Course Overview + Introduction to the Shell · Missing Semester
Fetch the sample data at https://microsoftedge.github.io/Demos/json-dummy-data/64KB.json with curl and use jq to extract just the names of people whose version is greater than 6. (Hint: pipe to jq . first to see the structure; then try jq '.[] | select(...) | .name') awk can filter lines based on column values and manipulate output.
🌐
discord.js
discord.js.org
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
🌐
jq
jqlang.org › manual
jq 1.8 Manual
This is useful when using jq as a simple calculator or to construct JSON data from scratch. ... Don't parse the input as JSON. Instead, each line of text is passed to the filter as a string. If combined with --slurp, then the entire input is passed to the filter as a single long string. ... Instead of running the filter for each JSON object in the input, read the entire input stream into a large array and run the filter just once.
Find elsewhere
🌐
OpenClaw
docs.openclaw.ai › automation › hooks
Hooks - OpenClaw
January 16, 2026 - # View recent commands tail -n 20 ~/.openclaw/logs/commands.log # Pretty-print with jq cat ~/.openclaw/logs/commands.log | jq . # Filter by action grep '"action":"new"' ~/.openclaw/logs/commands.log | jq . Enable: Copy · openclaw hooks enable command-logger ·
🌐
Zendesk Developer Docs
developer.zendesk.com › documentation › integration-services › developer-guide › jq-cheat-sheet
jq cheat sheet | Zendesk Developer Docs
To create an array, wrap the output in square brackets ([]). The following expression combines the collaborator_ids and submitter_id properties into a single array. ... Use the index filter to get the index of the first occurrence of an element in an array. If the element doesn't exist in the ...
🌐
Medium
medium.com › @buczynski.rafal › exploring-jq-a-guide-to-essential-techniques-and-tools-for-professionals-b9df9db490de
Exploring jq: A Guide to Essential Techniques and Tools for Professionals | by Rafał Buczyński | Medium
December 17, 2025 - This command filters out all objects in the array where the age field is greater than 30. The .[] syntax iterates over each element in the array, and the select function applies the specified condition.
🌐
Technitribe
blog.lnx.cx › 2019 › 09 › 09 › using-jq-to-filter-an-array-of-objects-from-json.html
Using jq to filter an array of objects from JSON | Technitribe
September 9, 2019 - $ jq '.prefixes | map(. | select(.service=="AMAZON"))' < ip-ranges.json | head [ { "ip_prefix": "18.208.0.0/13", "region": "us-east-1", "service": "AMAZON" }, Now we are getting each object returned as a member of an array. The difference is that we're putting the .prefixes array objects into the map function and telling it to iterate every object through the select function.
🌐
GitHub
gist.github.com › deepns › 5b28ac586c31cf9d3cd8e4aedbbc425b
Some examples of filtering JSON data using jq · GitHub
~ % cat stackexchange_sites | jq --raw-output '.items[] | .name' | sort | grep "^S" Seasoned Advice Seasoned Advice Meta Server Fault Stack Overflow Super User · We can also transform one json stream into another by specifying a filter with structure in { key : value} where value is the object to extract from the stream.
🌐
Remysharp
jq.remysharp.com › mapping
Map, Filter, Reduce
An array filter iterates over a collection, and if the precondition is met, then the current element is included in the result. There is no "native" filter method in jq directly akin to JavaScript, but it is fairly straight forward to replicate.
🌐
GitHub
github.com › jqlang › jq › issues › 684
Creating an array from objects? · Issue #684 · jqlang/jq
January 29, 2015 - First of all, kudos on such an excellent library...I've used jq for basic CLI tasks and have only recently delved into its more advanced functions, and am continually amazed at how things just work with few surprises...rare for a CLI tool that has so many features... So I think my question is pretty basic, and I'm missing something very obvious that could be clarified in the docs. Given a series of objects, what do I pipe them through to get them into an array?
Author   dannguyen
🌐
Reddit
reddit.com › r/commandline › jq: filter arrays inside an object
r/commandline on Reddit: jq: Filter arrays inside an object
May 10, 2025 -

Given the following JSON, how do I extract the multiple-phone arrays while skipping the single-phone objects?

{
  "phones": {
    "Alex Baker": {
      "location": "mobile",
      "number": "+14157459038"
    },
    "Bob Clarke": [
      {
        "location": "mobile",
        "number": "+12135637813"
      },
      {
        "location": "office",
        "number": "+13104443200"
      }
    ],
    "Carl Davies": [
      {
        "location": "office",
        "number": "+14083078372"
      },
      {
        "location": "lab",
        "number": "+15102340052"
        }
    ],
    "Drew Easton": {
      "location": "office",
      "number": "+18057459038"
    }
  }
}

Desired output:

{
  "Bob Clarke": [
    {
      "location": "mobile",
      "number": "+12135637813"
    },
    {
      "location": "office",
      "number": "+13104443200"
    }
  ],
  "Carl Davies": [
    {
      "location": "office",
      "number": "+14083078372"
    },
    {
      "location": "lab",
      "number": "+15102340052"
    }
  ]
}

The following jq query yields an empty JSON document:

jq '.phones | with_entries(select(arrays))' phones.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 - jq is really designed to process a sequence of values, which is why this has to unpack the array, filter it, and put it back into an array.
🌐
Claude
code.claude.com › docs › en › headless
Run Claude Code programmatically - Claude Code Docs
# Extract the text result claude -p "Summarize this project" --output-format json | jq -r '.result' # Extract structured output claude -p "Extract function names from auth.py" \ --output-format json \ --json-schema '{"type":"object","properties":{"functions":{"type":"array","items":{"type":"string"}}},"required":["functions"]}' \ | jq '.structured_output' Use --output-format stream-json with --verbose and --include-partial-messages to receive tokens as they’re generated. Each line is a JSON object representing an event: ... The following example uses jq to filter for text deltas and display just the streaming text.