调用接口返回String类型 public String send(String startDate, String endDate, String times, String type) { String url = PropertiesUtils.getProperty("Url"); Map<String, String> postParam = new HashMap<String, String>(); postParam.put("startDate",startDate); postParam.put("endDate",endDate); postParam.put("times",times); postParam.put("type",type); String dsjString= null; try { dsjString = HttpClientUtil.getDataByHttpClientFormPost(url,postParam); } catch (Exception e) { e.printStackTrace(); } return dsjString; }
if (dsjString != null && dsjString != ""){ JSONObject ret = JSONUtils.parseObject(dsjString); if (ret != null && ret.containsKey("code") && ret.getIntValue("code") == 0){ JSONArray jsonArray = ret.getJSONArray("data"); if (CollectionUtils.isNotEmpty(jsonArray)){ int iSize = jsonArray.size(); for (int i = 0 ; i < iSize ; i++){ JSONObject json = new JSONObject(); try { json = jsonArray.getJSONObject(i); } catch (JSONException e) { e.printStackTrace(); } if (json.getInteger("count") == 1){ time1 = json.get("nOrders"); } }