获得json数据
来源:互联网 发布:澳门网络博客公司顶级 编辑:程序博客网 时间:2024/05/29 04:46
//获取订单信息
Orders orders =ordersService.getById(model.getId());
//连接物流接口
String uri= "http://apis.haoservice.com/lifeservice/exp?"+"key=ef75f10b381c40038128e5cfd6e3c7a4" +
""+"&com="+orders.getWuliuCompany()+"&no="+orders.getWuliuNumber();
URL url =new URL(uri);
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),"utf-8"));//转码。
//获取返回的json数据
StringBuffer strBuf=new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null){
strBuf.append(line + " ");
}
reader.close();
//解析数据
JSONObject myJsonObject = JSONObject.fromObject(strBuf.toString());
JSONObject result=myJsonObject.getJSONObject("result");
JSONArray data=result.getJSONArray("data");
//为页面准备相应的数据
Result res=new Result();
res.setList(data.toList(data, Data.class));
res.setCom(result.getString("com"));
res.setCompany(result.getString("company"));
res.setNo(result.getString("no"));
res.setUpdatetime(result.getString("updatetime"));
ActionContext.getContext().put("result", res);
return "show";
Orders orders =ordersService.getById(model.getId());
//连接物流接口
String uri= "http://apis.haoservice.com/lifeservice/exp?"+"key=ef75f10b381c40038128e5cfd6e3c7a4" +
""+"&com="+orders.getWuliuCompany()+"&no="+orders.getWuliuNumber();
URL url =new URL(uri);
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream(),"utf-8"));//转码。
//获取返回的json数据
StringBuffer strBuf=new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null){
strBuf.append(line + " ");
}
reader.close();
//解析数据
JSONObject myJsonObject = JSONObject.fromObject(strBuf.toString());
JSONObject result=myJsonObject.getJSONObject("result");
JSONArray data=result.getJSONArray("data");
//为页面准备相应的数据
Result res=new Result();
res.setList(data.toList(data, Data.class));
res.setCom(result.getString("com"));
res.setCompany(result.getString("company"));
res.setNo(result.getString("no"));
res.setUpdatetime(result.getString("updatetime"));
ActionContext.getContext().put("result", res);
return "show";
0 0
- 获得json数据
- 获得json数据(表格)
- jquery_ajax get()获得json数据
- js通过变量获得json数据
- httpURLConnection获得网络数据解析json串
- 利用org.json处理获得的json数据
- 遍历json获得数据的几种方法
- 遍历json获得数据的几种方法
- 遍历json获得数据的几种方法
- 获得json数据的id或者说是key
- 遍历json获得数据的几种方法
- 遍历json获得数据的几种方法
- ios中调用webservice获得json格式的数据
- 遍历json获得数据的几种方法
- 遍历json获得数据的几种方法
- 从servlet获得json数据Ajax解析到前台网页
- [Android教程] android获得json数据并处理
- 遍历Json获得数据的几种方法
- 栈和堆的区别
- C++中引用和指针的区别
- MyBatis 学习总结---理论化知识点(一)
- MQTT(使用mosquitto做broker)做Android推送部分总结
- exec()函数
- 获得json数据
- 关注的技术
- rest_framework中的ModelSerializer
- UVa 10364 - Square
- neon基础知识
- 每日一练——Power of X
- ADB控制网络命令
- 自定义控件View的属性 以及declare-styleable中format详解网址
- 采集(file_get_contents)