如何使用键和值在JSON响应中发送Java列表

时间:2013-12-19 14:32:43

标签: java json spring-mvc

我正在使用spring mvc架构。当我解雇查询时,我得到了结果。 但我想要结果中的键值对。我的结果:

  {
   "searchResult":
   [
       [
           "hiteshp",
           121231,
           "Hitesh",
           "Patel",
           3,
           4,
           "false",
           "false",
           "GratZeez",
           23
       ],
       [
           "hiteshp",
           121231,
           "Hitesh",
           "Patel",
           3,
           4,
           "false",
           "false",
           "TGB",
           23
       ]
   ],
   "isError": "0",
   "message": "Search completed."
}

但我希望响应看起来像这样

{
   "searchResult":
   [
       [
           "userName":"hiteshp",
           "contactNo":121231,
           "firstName":"Hitesh",
           "lastName":"Patel",
           "avgRate":3,
           "userId":4,
           "shareRate":"false",
           "isImage":"false",
           "oName":"GratZeez",
           "oId":23
       ],
    "isError": "0",
   "message": "Search completed."
}

我的代码是用于解雇查询:

List<Map<String, Object>> objUserMasterList = null;
Map<String, Object> objMapUserMasterList = null;

objUserMasterList = (List<Map<String, Object>>)      this.commonService.getDataBySQLQuery(UserMaster.class, qStringUser,objMapProperties);

objMapUserMasterList.put("searchResult", objUserMasterList);
responseData.putAll(objMapUserMasterList);

0 个答案:

没有答案