With the below code I have converted list to json but the format is as follows:
{\"GodownMaster\":[{\"pname\":\"FCI CHARLAPALLI\",\"pcode\":\"16042\"},
Why are you putting your list into Map? Code looks weird. If you want to return a list, just do it:
@RequestMapping("/getGodowns")
public @ResponseBody List getGodownsBasedOnDistrict(@RequestParam(value="district_code") String dist_code) {
List godown_list = null;
String exception = null;
try {
//getting name and codes here
godown_list = scm_service.getGodownListBesedOnDistCode(dist_code);
} catch (Exception ex) {
ex.printStackTrace();
exception = ex.getMessage();
}
return godown_list;
}