方法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