1. 程式人生 > >fastjson獲取Json字串中資料

fastjson獲取Json字串中資料

通過介面請求到Json字串response

獲取Json字串rows中資料
JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = (JSONArray) ((JSONObject) jsonObject.get("content")).get("rows");
 List<Map<String, Object>> result = JSONArray.parseObject(jsonArray.toJSONString(), List.class);
獲取Json字串data中資料
JSONObject jsonObject = JSONObject.parseObject(response);
JSONObject data = jsonObject.getJSONObject("content").getJSONObject("data");

獲取到我們想要的資料和型別,再進行處理。