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

Answer from user3899165 on Stack Overflow
Discussions

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
Is it possible to output multiple values on a single line?
jq '.object1,.object2,.object3' returns the value for these objects each on a new line: "value1" "value2" "value3" Is there an option, or some filter to output these values on a single line, sepera... More on github.com
🌐 github.com
18
May 12, 2015
Option to return objects as a list of objects (separated by a comma)
I want to be able to parse the output from jq as json. At the moment it gives me: { "Name": "webserver-20130326", "ImageId": "ami-ef9bc192", "RootDevice... More on github.com
🌐 github.com
10
May 14, 2013
Using jq to parse and display multiple fields in a json serially - Stack Overflow
The next expression, [.first, .last], ... arrays as tab-separated and comma-seperated values, respectively. Similarly, it is possible to construct JSON values again, which is interesting if you just want to keep a subset of the fields: $ cat file.json | jq -c '.users[] | {first}' ... 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] ) ] | .[]'
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
🌐
jq
jqlang.org › manual
jq 1.8 Manual
If two filters are separated by a comma, then the same input will be fed into both and the two filters' output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs ...
🌐
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
🌐
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 - Both approaches extract targeted data while discarding unwanted properties. What is the difference between using comma (,) and pick() for field selection? The comma operator (,) runs multiple independent filters on the same input, producing separate output streams for each field.
Find elsewhere
🌐
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:
🌐
Caltech
sites.astro.caltech.edu › ~srk › Unix › SRKUnix › Tools › jq.txt
jq.txt
$ jq '.[995:] | .[] | .name' strikes.json "Tirupati" "Tissint" "Tjabe" "Tjerebon" "Tomakovka" You can apply functions as you go along $ jq '.[995:]| .[] | .name | length' strikes.json 8 7 5 8 9 To retrieve multiple values from each object we use a comma separated list $ jq '.[450:455] | .[] ...
🌐
GitHub
github.com › jqlang › jq › issues › 785
Is it possible to output multiple values on a single line? · Issue #785 · jqlang/jq
May 12, 2015 - jq '.object1,.object2,.object3' returns the value for these objects each on a new line: "value1" "value2" "value3" Is there an option, or some filter to output these values on a single line, seperated by commas (or another character): "v...
Published   May 12, 2015
Author   Reino17
🌐
Baeldung
baeldung.com › home › scripting › printing values in one line using the jq command
Printing Values in One Line Using the jq Command | Baeldung on Linux
March 18, 2024 - $ jq -r '.name, .age' sample_data.json test_user 30 · In the above output, we can see that both the values of name and age are printed on two different lines. The -r option ensures proper values are printed in plain text without any additional quotations. We can also customize the output by concatenating the multiple values with a custom separator. To demonstrate, let’s look at the command:
🌐
Bashoneliners
bashoneliners.com › oneliners › 332
Printing with jq multiple values in CSV or TSV formats | bashoneliners.com
October 13, 2023 - The jq command filters and transforms the JSON content: .[] for each object in the JSON array input, ... [.id, .name, .stargazers_count] create a JSON array from the object's fields ... @cvs convert a JSON array to a single string of comma separated values. The -r (or --raw-output) flag makes jq print the output as raw values, which makes string values printed without enclosing double-quotes.
🌐
Palmersteakhouse
palmersteakhouse.ca › educationai › jq-select-multiple-fields
jq select multiple fields
December 18, 2024 - echo '{"name": "John Doe", "age": 30, "city": "New York"}' | jq '.name' ... The simplest way to select multiple fields is to use the dot operator (.) followed by each field name, separated by commas, all enclosed in parentheses:
🌐
GitHub
github.com › jqlang › jq › issues › 124
Option to return objects as a list of objects (separated by a comma) · Issue #124 · jqlang/jq
May 14, 2013 - I want to be able to parse the output from jq as json. At the moment it gives me: { "Name": "webserver-20130326", "ImageId": "ami-ef9bc192", "RootDeviceType": "ebs", "State": "available" } { "Name": "webserver-20130328", "ImageId": "ami-4f9ac442", "RootDeviceType": "ebs", "State": "available" } { "Name": "webserver-20130402", "ImageId": "ami-efd341de", "RootDeviceType": "ebs", "State": "available" } What I want is the same, but with objects separated by commas:
Published   May 14, 2013
Author   boosh
🌐
GitHub
gist.github.com › olih › f7437fb6962fb3ee9fe95bda8d2c8fa4
jq Cheet Sheet · GitHub
JSON for how it's meant to work, along with output. I added an id field so we could clearly distinguish each object.
🌐
Programming Historian
programminghistorian.org › en › lessons › json-and-jq
Reshaping JSON with jq | Programming Historian
May 24, 2016 - Both of these commands are wrapped in [] which tells jq to collect every result into one single array, which is passed with a | along to: join(";"), which turns that array into one single character string, with semicolon delimiters between multiple tweet ids.