Here I have a excel file named Merged.xlsx. The figure of this is as:-

and I want this data to be displayed in a JSON format as:-
{
"Cars":[
{"SellerName":"govinda lamgade","Seller Address":"-Dallu,Kathmandu",...},
],
"Motorcycle":[
{Same as above},
]
}
So far I have got the result as
{"rows":[{"cell":["Skoda Rapid On Sale And Exchange"," govinda lamgade ","- Dallu, Kathmandu","19-06-2020",1450000.0,"https://cdn.hamrobazaar.com/21...
which is not the one that I wanted. The code is as:-
String excelFilePath = "E:\\Merged.xlsx";
FileInputStream fileInputStream = new FileInputStream(excelFilePath);
Workbook workbook = new XSSFWorkbook(fileInputStream);
Sheet sheet = workbook.getSheetAt(0);
JsonObject jsonObject = new JsonObject();
JsonArray rows = new JsonArray();
Iterator<Row> rowIterator = sheet.iterator();
while(rowIterator.hasNext()){
Row row = rowIterator.next();
if(row.getRowNum() == 0) {
continue;
}
else{
JsonObject jRow = new JsonObject();
JsonArray cells = new JsonArray();
Iterator<Cell> cellIterator = row.cellIterator();
while (cellIterator.hasNext()) {
Cell cell = cellIterator.next();
switch (cell.getCellType()) {
case Cell.CELL_TYPE_NUMERIC:
cells.add(cell.getNumericCellValue());
break;
case Cell.CELL_TYPE_STRING:
cells.add(cell.getStringCellValue());
break;
}
jRow.add("cell",cells);
rows.add(jRow);
}
jsonObject.add("rows", rows);
}
System.out.println(jsonObject.toString());
fileInputStream.close();
}
}
}
Thank You