You can use jq '.[] | .login, .id' to obtain each login followed by its id.

Answer from user3899165 on Stack Overflow
🌐
Earthly
earthly.dev › blog › jq-select
JQ Select Explained: Selecting elements from JSON with Examples - Earthly Blog
July 24, 2023 - $ echo '[{"a":"b"},{"a":"c"}]' | jq -r '.[].a' b c · To turn these values into a JSON array, what you do is similar to creating an array in JavaScript: You wrap the values in an array constructor ([...]). ... The GitHub issues API has a lot of details I don’t care about. I want to select multiple fields from the returned JSON document and leave the rest behind.
Discussions

json - Get field and nested field at the same time using jq - Unix & Linux Stack Exchange
> cat rm111.json | jq -r '.issues[] | .key .fields.summary' jq: error (at :18): Cannot index string with string "fields" I need to iterate over issues[] because there may be more than the one shown in this example. More on unix.stackexchange.com
🌐 unix.stackexchange.com
September 30, 2020
How do I select multiple keys for output?
This seems like a basic question but I can't find examples anywhere in the documentation. If I have input like - alpha: 1 beta: foo gamma: 0.3 delta: bar - alpha: 2 beta: baz gamma: 1.23 delta: buz... More on github.com
🌐 github.com
15
2
December 10, 2023
json - JQ: Select multiple conditions - Stack Overflow
3 How to select a object in jq that matches on a greater or less than for multiple values in a attribute More on stackoverflow.com
🌐 stackoverflow.com
Using jq, extract fields and subfields from a list of objects, grouping paired subfields for saving to csv - Unix & Linux Stack Exchange
Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
🌐
Mark Needham
markhneedham.com › blog › 2021 › 05 › 19 › jq-select-multiple-keys
jq: Select multiple keys | Mark Needham
May 19, 2021 - And then to flatten it out into single arrays instead of nested ones, we can pipe the result through the .[] selector: cat swagger-clean.json | jq -r '.paths | keys[] as $k | [ (.[$k] | keys[] as $k1 | [$k, $k1, .[$k1].operationId, .[$k1].summary] ) ] | .[]'
🌐
jq
jqlang.org › manual
jq 1.8 Manual
A jq program is a "filter": it takes an input, and produces an output. There are a lot of builtin filters for extracting a particular field of an object, or converting a number to a string, or various other standard tasks. Filters can be combined in various ways - you can pipe the output of one filter into another filter, or collect the output of a filter into an array. Some filters produce multiple results, for instance there's one that produces all the elements of its input array.
🌐
GitHub
gist.github.com › olih › f7437fb6962fb3ee9fe95bda8d2c8fa4
jq Cheet Sheet · GitHub
jq 'to_entries | map(select(.key | startswith("person."))) | from_entries' your.json · Copy link · Thank you, didn't know about the startwith. Its working now. Copy link · Selecting multiple fields and output them in one line per element. Additionally: round to two decimal precision ·
🌐
Gunnar Morling
morling.dev › blog › extracting-and-propagating-multiple-values-with-jq
Shell Spell: Extracting and Propagating Multiple Values With jq - Gunnar Morling
July 6, 2024 - jq is invaluable for handling JSON and I highly recommend spending some time with its reference documentation to learn about it. For the case at hand, the select() function is used within a pipeline for finding the right elements within the array of Terraform child modules and extracting the required values.
Find elsewhere
🌐
QC 4Blog
qc4blog.com › home › using jq to select multiple fields from json data
JQ Select Multiple Fields: A Comprehensive Guide
March 22, 2024 - For example, if we want to select all pets with names longer than 5 characters, we can use the following command: jq ‘.pets[] | select(.name | length > 5)’ data.json ... Now that we’ve covered the basics of selecting multiple fields with JQ, let’s explore some more advanced techniques ...
🌐
tutorialpedia
tutorialpedia.org › blog › how-do-i-select-multiple-fields-in-jq
How to Select Multiple Fields (Login and ID) in jq for NDJSON Files: A Step-by-Step Guide — tutorialpedia.org
If you want to exclude entries with missing fields instead of showing null, use select() as shown in Section 4.1. If output shows null for all login fields, check for typos (e.g., loggin instead of login). Use jq . to inspect the input structure: jq '.login' users.ndjson # Verify "login" exists in most entries · Extracting multiple fields (like id and login) from NDJSON files with jq is a straightforward process once you master object construction and filtering.
🌐
HackingNote
hackingnote.com › en › cheatsheets › jq
Cheatsheet - jq
Multiple fields: # from top level $ cat file.json | jq '. | {field1, field2}' # from sub level $ cat file.json | jq '.results[] | {id, name}' Extract as text values instead of JSON (getting rid of quotes), use -r: $ cat file.json | jq -r '.a.b[0].c' Slice an array · $ echo '["a", "b", "c", "d"]' | jq '.[1:3]' # get "name" of id 1 $ cat file.json | jq '.results[] | select(.id == "1") | {name}' ...
🌐
iO Flood
ioflood.com › blog › jq-select
The jq 'select' Command | Your Key to JSON Data Filtering
November 16, 2023 - The jq 'select' command is used to filter JSON data based on specific conditions, with the syntax jq 'select(.key "condition")', which. It’s a powerful tool that allows you to extract specific data from a JSON object based on the conditions you set. ... In this example, we’re using the jq ‘select’ command to filter a JSON object.
🌐
Nhanvietluanvan
nhanvietluanvan.com › trang chủ › efficiently selecting multiple fields with jquery: a comprehensive guide
Efficiently Selecting Multiple Fields With Jquery: A Comprehensive Guide
July 7, 2023 - For example, if you have a JSON object with a “status” field and you want to select only the fields where the status is “active”, you can use the following command: “` jq ‘select(.status == “active”)’ file.json “` This command will output only the fields where the “status” field is “active”. 3. Performing complex field selections: jq provides a lot of flexibility in selecting fields based on multiple criteria.
🌐
CopyProgramming
copyprogramming.com › howto › jq-select-multiple-fields-from-array
Mastering jq: Selecting Multiple Fields from Arrays and 2026 Best Practices - Jq select multiple fields from array
November 21, 2025 - This practice prevents null pointer exceptions and data corruption in consuming applications. jq 1.8.1 is the latest stable version for 2026, offering security fixes and performance improvements over earlier releases · The pick() function provides the cleanest syntax for selecting multiple ...
🌐
Qmacro
qmacro.org › blog › posts › 2022 › 05 › 28 › multiple-level-filters-in-jq
Multiple level filters in jq - DJ Adams
May 28, 2022 - Then I loaded it into ijq, the lovely interactive frontend to jq, and played around a bit. ... .value gives me the entire array of objects in the dataset, each one of which represents a supplier with all their products · map(...) this outer map takes the array of supplier and product data and produces a new array, having processed each array element (each supplier with their products) with the filter expression supplied · select(.Country == "UK") this is the equivalent of the $filter=Country eq UK in the OData URL
Top answer
1 of 2
4

You want to run a .context,.score filter on each element of v I think:

$ jq -r '.[] | [.c, .e, .score, (.v[] | .context,.score)] | @csv' file.json
"A","B",0.99,"asdf",0.98,"bcdfd",0.97

This is equivalent to using the builtin map function without assembling the results back into an array.

2 of 2
2

The following creates a JSON-encoded CSV record for each top-level array element, and then extracts and decodes them. For each of the top-level elements, the values of the sub-array is incorporated by "flattening" the array.

jq -r 'map([ .c,.e,.score, (.v|map([.context, .score])) ] | flatten | @csv)[]' file

Given a test document equivalent of the following:

[
   {
      "c": "A",
      "e": "B",
      "score": 0.99,
      "v": [
         { "context": "asdf", "score": 0.98, "url": "..." },
         { "context": "bcdfd", "score": 0.97, "url": "..." }
      ]
   },
   {
      "c": "A",
      "e": "B",
      "score": 0.99,
      "v": [
         { "context": "asdf", "score": 0.98, "url": "..." },
         { "context": "asdf", "score": 0.98, "url": "..." },
         { "context": "bcdfd", "score": 0.97, "url": "..." }
      ]
   },
   {
      "c": "A",
      "e": "B",
      "score": 0.99,
      "v": [
         { "context": "asdf", "score": 0.98, "url": "..." },
         { "context": "asdf", "score": 0.98, "url": "..." },
         { "context": "asdf", "score": 0.98, "url": "..." },
         { "context": "bcdfd", "score": 0.97, "url": "..." }
      ]
   }
]

... we get

"A","B",0.99,"asdf",0.98,"bcdfd",0.97
"A","B",0.99,"asdf",0.98,"asdf",0.98,"bcdfd",0.97
"A","B",0.99,"asdf",0.98,"asdf",0.98,"asdf",0.98,"bcdfd",0.97

One could also reorder the operations so that a single use of the @csv operator gets a set of arrays (rather than repeatedly using @csv on single arrays):

jq -r 'map([ .c,.e,.score, (.v|map([.context, .score])) ] | flatten)[]|@csv' file
🌐
DcodeSnippet
dcodesnippet.com › home › programming › mastering jq select multiple fields for efficient data manipulation
Mastering Jq Select Multiple Fields For Efficient Data Manipulation | DcodeSnippet
May 12, 2024 - Learn how to efficiently select multiple fields using jq for improved data manipulation. Explore benefits, implementation steps, and troubleshooting tips.