您的位置:首页 > Web前端 > JavaScript

关于json数组的解析

2016-07-27 00:00 417 查看
摘要: 调用接口返回String类型的json数组

调用接口返回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");
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: