Get outputs from jq on a single line

Solution 1:

-c is what you likely need

Using the output you posted above, you can process it further:

jq -c . input

To Give;

{"key":"SEA-739","status":"Open","assignee":null}
{"key":"SEA-738","status":"Resolved","assignee":"[email protected]"}

Or you can just change your original command

FROM

jq -r '(.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress})'

TO

jq -c '(.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress})'

Solution 2:

Not precisely an answer to the long version of the question, but for people who Googled this looking for other single line output formats from jq:

$ jq -r '[.key, .status, .assignee]|@tsv' <<<'
 {
   "key": "SEA-739",
   "status": "Open",
   "assignee": null
 }
 {
   "key": "SEA-738",
   "status": "Resolved",
   "assignee": "[email protected]"
 }'
SEA-739 Open
SEA-738 Resolved        [email protected]

@sh rather than @tsv returns:

'SEA-739' 'Open' null
'SEA-738' 'Resolved' '[email protected]'

Additionally, there are other output formats to do things such as escape the output, like @html, or encode it, as with @base64. The list is available in the Format strings and escaping section of either the jq(1) man page or online at stedolan.github.io/jq/manual.