How to get Json in Android
2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址:https://cloud.tencent.com/act/cps/redirect?redirect=1062
2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址:https://www.aliyun.com/minisite/goods
推荐:android JSON
1、JSON(JavaScript Object Notation) 定义: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性。业内主流技术为其提供了完整的解决方案(有点类
Json包如下
[{"cityinfo":{"areaid":"101010100","namecn":"北京","districtcn":"北京","provcn":"北京","nationcn":"中国","lon":"116.391","lat":"39.904","time":"20140120144758","time_zone":"GMT+8:00","zone_abb":"CST","dst":"0"}},{"l":{"l1":"3","l2":"19","l3":"4","l4":"8","l5":"00","l6":"0","l7":"14:35"}}]。
包中共有2个分组,故要取得分别对应的数值,可做如下处理
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。 易于人阅读和编写。同时也易于机器解析和生成。JSON采用完全独立于语言的文本格式,但是也使用
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); for (String s = reader.readLine(); s != null; s = reader.readLine()) { builder.append(s); } Log.i("json_str", builder.toString()); jsonArray = new JSONArray(builder.toString()); JSONObject jsonObject = jsonArray.getJSONObject(0); Log.i("city", jsonObject.getJSONObject("cityinfo").getString("namecn")); jsonObject = jsonArray.getJSONObject(1); Log.i("temp", jsonObject.getJSONObject("l").getString("l1")); Log.i("wather", jsonObject.getJSONObject("l").getString("l5"));
推荐:Android Json
protected void sendJson(final String email, final String pwd) { Thread t = new Thread(){ public void run() { Looper.pr
相关阅读排行
- 1android json解析及简单例子
- 2android json解析
- 3Android中的JSON详细总结
- 4Android上基于JSON的数据交互应用
- 5ANDROID轻量级JSON序列化和反序列化