將物件解析成json字串
阿新 • • 發佈:2019-02-04
將一個list集合進行解析
List<ConfModuleAppResp> list = this.confModuleAppServiceClient.findList(queryModel).get().getContent();
解析方法:
String Josonlist=JsonUtils.toJson(list);
解析成如下格式:
[ { "id": "A0qfMbpEujo0rDPF", "moduleName": "裝置設定授權", "moduleIcon": "http://demo.mobcb.com/zimgs/5028fc530f696351e8171ec9907c0980?f=PNG", "urlType": "3", "urlParam": "229", "parentId": "0", "isDisplay": 1, "createTime": 1500861122, "modifyTime": 1500973833, "orderNo": 6, "background": "#3fbeff", "groupId": "2", "appInfo": { "id": "15", "appName": "商管端", "description": "商管端", "appKey": "management_mall", "createTime": 1488534020 } }, { "id": "A0qf5ZWuKbhaHX4W", "moduleName": "無單退貨授權", "moduleIcon": "http://demo.mobcb.com/zimgs/df98e140483da064d099ebc0a3a2f14d?f=PNG", "urlType": "3", "urlParam": "215", "parentId": "0", "isDisplay": 1, "createTime": 1500861003, "modifyTime": 1500973845, "orderNo": 5, "background": "#55d2c2", "groupId": "2", "appInfo": { "id": "15", "appName": "商管端", "description": "商管端", "appKey": "management_mall", "createTime": 1488534020 } }
]
通過
List<Map<String, Object>> infoJsonList = (List<Map<String, Object>>) JsonUtils .toObject(JsonUtils.toJson(list), List.class);
將json字串轉換成鍵值對的形式。