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

Answer from user3899165 on Stack Overflow
Discussions

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
json - jq - print values in one line - 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
June 23, 2018
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
How can I use jq to filter only certain fields of the original JSON into an CSV?
In Ruby, "because it was there." cat foo.json | ruby -e 'require "json"; JSON.parse(STDIN.read).each do |line|; output=[]; line.each do |x,y|; output.push(y) if (x!="env"); end; puts output.join(","); end' foo,1.24 bar,1.21 boo,1.23 far,1.24 More on reddit.com
🌐 r/linuxquestions
2
5
February 17, 2023
🌐
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] ) ] | .[]'
🌐
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 '.[] | select(.age > 30) | .name' sample_array.json Bob · In the above output, we can see only Bob as its age is greater than 30. In this article, we explored various ways to print values in a single line using the jq command. First, we created a sample JSON object and JSON array for processing and manipulation. After that, we manipulated JSON objects to extract some values. Later, we also performed the same manipulation on a nested JSON array.
🌐
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 - For the case at hand, the select() ... child modules and extracting the required values. Putting the two inner select() calls into parenthesis makes them two separate expressions whose output will go onto separate lines....
🌐
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 ·
🌐
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, sepera...
Published   May 12, 2015
Author   Reino17
Find elsewhere
🌐
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 - Doing the describe is easy using the Salesforce REST API but when using jq different are usually on different lines like below (-r is a nifty switch for getting raw, unquoted strings). $ 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
🌐
Earthly
earthly.dev › blog › jq-select
JQ Select Explained: Selecting elements from JSON with Examples - Earthly Blog
July 24, 2023 - The -r option in jq gives you raw strings if you need that. ... The -j option (for join) can combine together your output. ... Once you start using the array index to select elements, you have a new problem.
🌐
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.
🌐
Reddit
reddit.com › r/linuxquestions › how can i use jq to filter only certain fields of the original json into an csv?
r/linuxquestions on Reddit: How can I use jq to filter only certain fields of the original JSON into an CSV?
February 17, 2023 -

Hello, I say this stack overflow anser with a simple jq command to convert a JSON to a csv file, but I need to improve it further.

Say I have the following JSON:

[
    {
        "name": "foo",
        "env": "dev",
        "version": "1.24"
    },
    {
        "name": "bar",
        "env": "staging",
        "version": "1.21"
    },
    {
        "name": "boo",
        "env": "prod",
        "version": "1.23"
    },
    {
        "name": "far",
        "env": "prod",
        "version": "1.24"
    }
]

How does one create the CSV with only the "name" and "version" fields?

My current command is:

jq -r '(map(keys) | add | unique) as $cols | map(.[] | {name, version} as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv'

This is not working. Can anyone provide some help?

Thanks!

🌐
MAC Address Lookup
aruljohn.com › home › articles › tech
jq Command for JSON Processing with Practical Examples
October 10, 2024 - If we want to print multiple values on the same line, we use -r and String Interpolation, like this: $ echo '{"first_name": "Arul", "last_name": "John"}' | jq -r '"\(.first_name) \(.last_name)"' Arul John ·
🌐
GitHub
github.com › mikefarah › yq › issues › 287
How do I select multiple keys for output? · Issue #287 · mikefarah/yq
October 29, 2019 - How do I do it? Every example in the documentation is only selecting a single key. The equivalent in jq would be something like: jq '.[] | .beta, .delta' or · jq '.[] | {beta, delta}' Reactions are currently unavailable · No one assigned · enhancement · No projects ·
Author   ronniegane
🌐
Zendesk Developer Docs
developer.zendesk.com › documentation › integration-services › developer-guide › jq-cheat-sheet
jq cheat sheet | Zendesk Developer Docs
Combine the array index and object identifier-index filters to get a property from an array of objects. The following expression gets the id of the second object in the custom_fields array.