DEV Community

List non-empty fields of Jira ticket

Let's assume you have saved payload received using Jira REST API to file jiraTask.json.

$ jiraGet issue/BOOM-666 > jiraIssue.json
Enter fullscreen mode Exit fullscreen mode

You can read more about Super-simple Jira API in


Then you can list non-empty fields of the ticket using the folowing command (make sure you have installed jq before):

$ jq --raw-output '
    .fields | 
    . as $f |
    keys[] | 
    select($f[.] != null)
' jiraIssue.json

...<87 fields listed>...
Enter fullscreen mode Exit fullscreen mode

In my example, the command above lists 87 non-empty fields of Jira ticket. Compare it with total number of fields in the ticket which is 983 😱

Or, if you want to see fields with their values, use the following:

$ jq --raw-output '
    .fields | 
    . as $f | [ 
        keys[] | 
        select($f[.] != null) | 
        { (.): $f[.] } 
    ] | 
    add
' jiraIssue.json
Enter fullscreen mode Exit fullscreen mode

Top comments (0)