方法1:
現將string轉化成JSONObject,利用jsonObject的getJsonArray(String key)方法,獲取只包含jsonArray的部分Json數組,再利用jsonArray的getJSONObject(int index)方法獲取數組的某個JsonObject,再通過JsonObject.parse(string,Object.class)來轉換成javaBean
String res = HttpClientUtil.doPost(checkUrl, param, headers, "utf-8"); JSONObject jo = JSONObject.parseObject(res); JSONArray rows = jo.getJSONArray("rows");
方法2:
String res=getCustInfo.getCustListInfoByName(user,custName);
String res1= JSONObject.parseObject(res).getString("rows");
JSONArray list=JSONObject.parseArray(res1);
//Customer customer=JSONObject.parseObject(list.getJSONObject(0).toJSONString(),Customer.class);
方法1比方法2要簡單一些,
方法1:String-》JsonObject-》jsonArray
方法2:String-》JsonObject-》String-》JsonArray