Converting JSON output to csv

Alla Kennedy September 21, 2017

Is there a way to get data from REST API in a csv format instead of JSON without additional converters?

Raw JASON comes with a lot of extra data, we are having problems flattening it.

Need to GET a list of issues.

 

2 answers

0 votes
Alla Kennedy September 21, 2017

I need to create a batch job that sends updates from JIRA to an external database. The only way I see it is through REST.

Looking into PowerShell now and Invoke-RestMethod looks promising. Are there any good sources for JIRA REST code in PowerShell? All REST tutorials seem to be in old command-line curl.

Alla Kennedy September 21, 2017

Sorry, that should have been a Reply to Nic, not a separate Answer..

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2017

I don't know, I've not used PowerShell since I gave up on Window many many years ago.

The xml and csv should still work though, they come over plain http(s) with no formatting.

Alla Kennedy September 21, 2017

So is it possible to grab JIRA data in plain xml and csv automatically, without going to JIRA and exporting it manually?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2017

Yes, just hit the url the issue navigator links to for an xml or csv export.

Alla Kennedy September 21, 2017

I apologize if I am not expressing myself clearly. Manual CVS export from Jira is not suitable for our needs. I need to create an issue list programmatically, so I can:

1-run it automatically as a batch, e.g. through the scheduler;

2-have more control over columns selection , ordering, data formatting, data display etc. I am facing many, many problems with the data exported manually through Jira's Export facility. Data that I get through REST seems more accurate, but I have to deal with JSON.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2017

I don't understand?  If you can hit a REST url, you can fetch an http one the same way.

The data you get from REST is just as "accurate" as what you get from CSV or xml links, it's just a different format (although I'd say JSON and xml are better representations than xml)

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 21, 2017

No, it's JSON only.

One of the reasons REST throws out JSON is that CSV is generally too simple to represent some of the data usefully.  I suspect the problem you're having "flattening JSON" is because the data simply doesn't fit into a CSV layout.

However, you don't have to use REST - you could also hit the urls in the issue navigator that provide the results of filters as xml or csv.  Run a search and look for the export options

Suggest an answer

Log in or Sign up to answer