json解析陣列和物件
阿新 • • 發佈:2019-02-02
com.alibaba.fastjson.JSONObject jso = null; try { jso = JSON.parseObject(result);//json字串轉換成jsonobject物件 JSONArray objects = jso.getJSONArray("data");//jsonobject物件取得some對應的jsonarray陣列 for (int i = 0; i < objects.size(); i++) { String str = (String) objects.get(i); }
} catch (Exception e) {
e.printStackTrace();
}
json模型:
{ "appId": "", "count": "0", "currentPageNum": "20", "data": [], "ext": { "sysdate": "2017-10-11 14:12:59" }, "id": "", "numPerPage": "20", "object": { "offlineCouponCount": "0", "onlineCouponCount": "0", "platformCouponCount": "0" }, "pageNum": "1", "retCode": "000", "retDesc": "", "rtn": true, "rtnMsg": "操作成功", "sequenceName": "", "serNo": "", "terminal": "", "totalCount": "0", "totalPage": "0", "version": "1.01" }