jsonString转实体类

tech2022-12-03  99

JSONObject jsonObject = JSONObject.parseObject(body); JSONArray jsonArray = new JSONArray(); Object object = jsonObject.get("msg"); if(object instanceof JSONObject) { jsonArray.add(object); } else if(object instanceof JSONArray) { jsonArray = jsonObject.getJSONArray("msg"); } String type = jsonArray.getJSONObject(0).get("type").toString(); String imei = jsonArray.getJSONObject(0).get("imei").toString(); List<OneNetMsgVo> msgVos = JSONObject.parseArray(jsonArray.toJSONString(), OneNetMsgVo.class); OneNetEventVo eventVo = JSONObject.parseObject(jsonArray.getString(0), OneNetEventVo.class);
最新回复(0)