I have the JSON data that i have got from making a post call to a url, I printed out the JSON data in the console but I need to read that JSON data and get the excel output.
Asked
Active
Viewed 34 times
1 Answers
0
By Excel, I assume you meant CSV format. It is a format viewable on Excel.
to do it manually: http://www.convertcsv.com/json-to-csv.htm
to do it programmatically: How can I convert JSON to CSV?
In java, the following code is to write to CSV. To write JSON object, you will need to extract which part of the JSON object you want to write because JSON has objects like maps which cannot be simply written into table format. Let me know if it is not clear.
)
private static void generateCsvFile(String sFileName) {
try
{
FileWriter writer = new FileWriter(sFileName);
// Start a row
writer.append("Column1");
writer.append(',');
writer.append("Column2");
writer.append('\n');
// Start a new row
writer.append("Row2Column1");
writer.append(',');
writer.append("Row2Column2");
writer.append('\n');
writer.flush();
writer.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
Use it:
generateCsvFile("/path/sample.csv");

Community
- 1
- 1

Alec Zhang
- 129
- 6
-
yes, it is excel format. And In order to do it programmatically, I am using java. Can you suggest me sample java based code to convert JSON data into csv/excel? – Abdullah Faruk Nov 19 '15 at 14:06
-
Can you respond to the answer? – Alec Zhang Nov 24 '15 at 19:57