convert list to json using Jackson

后端 未结 4 1178
灰色年华
灰色年华 2020-12-21 02:04

With the below code I have converted list to json but the format is as follows:

{\"GodownMaster\":[{\"pname\":\"FCI CHARLAPALLI\",\"pcode\":\"16042\"},
         


        
4条回答
  •  爱一瞬间的悲伤
    2020-12-21 02:51

    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;
    }
    

提交回复
热议问题