0

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.

Abdullah Faruk
  • 913
  • 8
  • 8

1 Answers1

0

By Excel, I assume you meant CSV format. It is a format viewable on Excel.

  1. to do it manually: http://www.convertcsv.com/json-to-csv.htm

  2. to do it programmatically: How can I convert JSON to CSV?

  3. 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