adonislu 2017-05-15
便于前端解析,需要转化。这里选择的是net.sf.json包。
//获取物流实体 JSONObject jc = JSONObject.fromObject(resultTrace); JSONArray jd = jc.getJSONArray("Traces"); List<JSONObject> list = new ArrayList<JSONObject>(); if(jd.size()>0){ for(int i=0;i<jd.size();i++){ Map<String, Object> map = new HashMap<String, Object>(); JSONObject jsonObject = jd.getJSONObject(i); String acceptTime = (String) jsonObject.get("AcceptTime"); String acceptStation = (String) jsonObject.get("AcceptStation"); map.put("acceptTime", acceptTime); map.put("acceptStation", acceptStation); list.add(JSONObject.fromObject(map)); } } return list;