I got below output using: https://stackoverflow.com/a/40330344
(.issues[] | {key, status: .fields.status.name, assignee: .fields.assignee.emailAddress})
Output:
{ "key": "SEA-739", "status": "Open", "assignee": null } { "key": "SEA-738", "status": "Resolved", "assignee": "[email protected]" }
But I need to parse each and every line but it's tough to identify which assignee is for which key as far as key group is concerned. Is this possible to make one bunch in one row using jq?
Expected output:
{ "key": "SEA-739", "status": "Open", "assignee": null } { "key": "SEA-738", "status": "Resolved", "assignee": "[email protected]"}
OR
{ "SEA-739", "Open", null } { "SEA-738", "Resolved", [email protected] }
JSONPath distinguishes between the "root object or element" ($) and "the current object or element" (.). jq simply uses . to refer to the current JSON entity and so it is context-dependent: it can refer to items in the input stream of the jq process as a whole, or to the output of a filter.
jq is a lightweight and flexible command-line JSON processor. It is like sed for JSON data – you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text. jq is a fantastic command-line JSON processor.
jq is an amazing little command line utility for working with JSON data.
-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})'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With