JSONObject

匿名 (未验证) 提交于 2019-12-03 00:40:02
 JSONObject paramJson = JSONObject.parseObject(param);         if (!paramJson.containsKey("peerTime")) {             throw new BaseException(ErrorCodeEnum.CODE_DB_CONNECT_ERROR, "set peer param must contains param peerTime");         }
数组
"statisticsInfo": [{ "idType": 0, "id": "1234567" },{ "idType": 1, "id": "1234567" }]
List<JSONObject> statisticsInfoJson = JSONArray
.parseArray((paramJson.get("statisticsInfo")).toString(), JSONObject.class);
List<StatisticsIdEntity> statisticsIds = new ArrayList<>(statisticsInfoJson.size());
for (JSONObject jsonObject : statisticsInfoJson) {
StatisticsIdEntity statisticsIdEntity = new StatisticsIdEntity();
statisticsIdEntity.setIdType(Short.valueOf(String.valueOf(jsonObject.get("idType"))));
statisticsIdEntity.setIdValue(String.valueOf(jsonObject.get("id")));
statisticsIds.add(statisticsIdEntity);
}
 

参数格式如下(areaCode是区域码,deviceId是点位id)

[{

       "areaCode": "12345",

       "deviceId": "12345"

},

{

       "areaCode": "12346",

       "deviceId": "12346"

}]

List<Map> areDeviceIds=JSONArray.parseArray(areaDeviceIds, Map.class)

 

JSONObject

原文:https://www.cnblogs.com/xjatj/p/9272186.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!