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

Answer from user3899165 on Stack Overflow
๐ŸŒ
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.
Discussions

JQ and Multiple Fields with a SELECT - Stack Overflow
echo "$json_string" | jq '.checks | .[] | select(.status != "OK")' More on stackoverflow.com
๐ŸŒ stackoverflow.com
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 - Get field and nested field at the same time using jq - Unix & Linux Stack Exchange
> cat rm111.json | jq -r '.issues[] | .key' RM-111 > cat rm111.json | jq -r '.issues[] | .fields.summary' 6.6.0 More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
September 30, 2020
json - Select multiple fields using jq - Stack Overflow
Communities for your favorite technologies. Explore all Collectives ยท Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
๐ŸŒ stackoverflow.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] ) ] | .[]'
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 79569370 โ€บ jq-and-multiple-fields-with-a-select
JQ and Multiple Fields with a SELECT - Stack Overflow
# jq 1.7+ jq '.checks[] |= select(.status != "OK")' <<< "$json_string" # jq 1.3+ jq '.checks |= map(select(.status != "OK"))' <<< "$json_string"
๐ŸŒ
Earthly
earthly.dev โ€บ blog โ€บ jq-select
JQ Select Explained: Selecting elements from JSON with Examples - Earthly Blog
July 24, 2023 - Itโ€™s similar to the WHERE clause in a SQL statement or array filter in JavaScript. Like map, I find select comes up quite a bit, so while you may have to come back to this article or google it the first few times you need it, with luck, it will start to stick to your memory after that. ... curl https://api.github.com/repos/stedolan/jq/issues?per_page=100 | \ jq 'map({ title: .title, number: .number, labels: .labels | length }) | map(select(.labels > 0))'
๐ŸŒ
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.
๐ŸŒ
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 ...
Find elsewhere
๐ŸŒ
Palmersteakhouse
palmersteakhouse.ca โ€บ educationai โ€บ jq-select-multiple-fields
jq select multiple fields
December 18, 2024 - The select function allows for more complex scenarios where you might only want to select certain fields based on a condition. Let's say you want to select only fields with string values: echo '{"name": "John Doe", "age": 30, "city": "New York", "isActive": true}' | jq 'select(type == "string")'
๐ŸŒ
Lekkimworld
lekkimworld.com โ€บ 2018 โ€บ 09 โ€บ 07 โ€บ jq-and-multi-field-output-to-csv
jq and multi-field output to CSV โ€“ lekkimworld.com
September 7, 2018 - $ sfdx force:schema:sobject:describe -s Account -u myorg --json | jq -r ".result.fields[] | .label, .name" Age Age__pc PO Box PO_Box__pc Postal Code Before City Postal_Code_Before_City__pc Street No Before Street Street_No_Before_Street__pc Archived State Archived_State__pc
๐ŸŒ
GitHub
gist.github.com โ€บ olih โ€บ f7437fb6962fb3ee9fe95bda8d2c8fa4
jq Cheet Sheet ยท GitHub
jq 'to_entries | map(select(.key | startswith("person."))) | from_entries' your.json ... Thank you, didn't know about the startwith. Its working now. ... Selecting multiple fields and output them in one line per element.
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
๐ŸŒ
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 some NDJSON entries lack id or login, jq will set the missing field to null (as seen in the 4th entry of our sample file). To omit entries with missing fields instead of setting null, use select() to filter objects that have both fields: