public static void main(String[] args) { //客户端json方式访问服务端 JSONObject json = new JSONObject(); json.put("vin", "FX003054"); String result = AdvancedUtil.httpTextRequest("http://localhost:8080/ECMS/maintainRecord/inspection", null, "POST", json.toString(), null); System.out.println(result); //取得json返回值 String a = "{"carlist":[{"carno":"FX003905"},{"carno":"FF"}],"retval":1,"total":1}"; JSONObject resultJson = JSONObject.fromObject(a); System.out.println(resultJson.getString("retval"));//取JSON中跟数组同级值 JSONArray jsonArray = resultJson.getJSONArray("carlist");//取JSON数组中值 if(jsonArray != null && jsonArray.size() > 0){ for(int i = 0;i<jsonArray.size();i++){ JSONObject JSONCar = jsonArray.getJSONObject(i); System.out.println(JSONCar.get("carno")); } } } }