Are you receiving SNAP/EBT or WIC benefits? The Expensify.org/SNAP-WIC-VAX campaign is live and accepting new members. Learn more about receiving $50 for submitting a SNAP/WIC receipt and $50 for getting your COVID-19 vaccine here and join today!
Comma missing in JSON reponse for report exporter

HI I'm trying to export the report through report exporter API.I want my response to be in JSON.
I use the following template
<#if addHeader>[</#if>
<#list reports as report>
{
"accountId": "${report.accountID}",
"reportId": "${report.reportID}",
"status": "${report.status}",
"submitDate": "${report.submitted}",
"createdDate": "${report.created}",
"currency": "${report.currency}"
}<#if report?has_next>,</#if>
</#list>
<#if addFooter>]</#if>
Comma is missing after some json objects.Is there any mistakes in the template?
Answers
-
I think there are several things wrong with this template. (missing headers, wrong format)
Check out the template that I use to download a report
<#if addHeader>
Merchant,Amount,Transaction Date<#lt>
</#if>
<#list reports as report>
<#list report.transactionList as expense>
<#if expense.modifiedMerchant?has_content>
<#assign merchant = expense.modifiedMerchant>
<#else>
<#assign merchant = expense.merchant>
</#if>
<#if expense.convertedAmount?has_content>
<#assign amount = expense.convertedAmount/100>
<#elseif expense.modifiedAmount?has_content>
<#assign amount = expense.modifiedAmount/100>
<#else>
<#assign amount = expense.amount/100>
</#if>
<#if expense.modifiedCreated?has_content>
<#assign created = expense.modifiedCreated>
<#else>
<#assign created = expense.created>
</#if>
${merchant},<#t>
${amount},<#t>
${created}<#lt>
</#list>
</#list>
I hope this helps.
-
Hi
Thanks for your reply
I want to download the report in json format and not in csv format.
If i use the above template even after giving .json as file extension in output settings, the result is in csv format and not json format
Also please note that i have added "[" in header and footer and written template in key value pairs format
Let me know if there is any way to obtain the report in json format
-
I don't think you can download that file on a different format other than a .csv
Why don't you use a function to convert your .csv into json?
I am not sure exactly what are you using for coding but here are some examples.
https://www.geeksforgeeks.org/convert-csv-to-json-using-python/
http://brianvanderplaats.com/2015/10/08/generating-json-from-csv-using-powershell/