jsonObject和jsonArray转换

String paramJSON = JSON.toJSONString(param);

//接口返回json
String Response = doHttpGet(URL, header, param);
//String转Object
JSONObject ResponseJson = JSONObject.parse(Response);
//Object转Array
JSONArray data = ResponseJson.getJSONArray("data");
//Array取值转object
JSONObject site = data.getJSONObject(i);
//object取值
site.getString("parentId")
//把jsonobject 放到数组里(fastjson)
JSONArray jsonArray = new JSONArray();
jsonArray.add(groups.get(k));
posted @ 2024-12-19 10:39  血染星辰  阅读(166)  评论(0)    收藏  举报