Skip to content
Advertisement

apache poi convert excel to json [closed]

ExcelToJson converter

JavaScript

The method works correctly, but at the output it produces an array, which I then need to write to the database. This array forms one object and the data cannot be written to the database. Is it possible that the data would come not as an array, but as a simple list?

Advertisement

Answer

I think you can follow the below code snippet and convert the JSON array into a Java array list that you need.

Add these classes in your import,

JavaScript

You can create a separate method using the below code and call it in a place where you are going to pass the JSON array to get the List. While using it remove the sample JSON data and the JSON object creation part as you will be already having the JSON array with you. Pass the JSON array as a parameter and start adding the JSON data into your list.

JavaScript

Output:

JavaScript

If you have any further doubts refer to here

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement