栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Android中的Json解码

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android中的Json解码

可以使用以下代码解析此json。

str="<The Json>"try {         JSonObject jObject=new JSonObject(str);         JSonArray menuObject = new JSonArray(jObject.getString("udeals"));         for (int i = 0; i<menuObject.length(); i++) {  System.out.println("length="+menuObject.length());  System.out.println("vName="+menuObject.getJSonObject(i)          .getString("vName"));  System.out.println("vAddress="+menuObject.getJSonObject(i).getString(          "vAddress"));  System.out.println("vState="+menuObject.getJSonObject(i)          .getString("vState"));  System.out.println("vZip="+menuObject.getJSonObject(i).getString(          "vZip"));  System.out.println("vCountry="+menuObject.getJSonObject(i)          .getString("vCountry"));  System.out.println("dealCategoryID="+menuObject.getJSonObject(i)          .getString("dealCategoryID"));  System.out.println("dealCaption="+menuObject.getJSonObject(i).getString(          "dealCaption"));  System.out.println("dealImage="+menuObject.getJSonObject(i)          .getString("dealImage"));  System.out.println("dealPrice="+menuObject.getJSonObject(i).getString(          "dealPrice"));  System.out.println("dealCost="+menuObject.getJSonObject(i)          .getString("dealCost"));  System.out.println("dealSave="+menuObject.getJSonObject(i).getString(          "dealSave"));  System.out.println("dealOfferRate="+menuObject.getJSonObject(i)          .getString("dealOfferRate"));  System.out.println("jsDeadLine="+menuObject.getJSonObject(i).getString(          "jsDeadLine"));  jsDeadLine=menuObject.getJSonObject(i).getString("jsDeadLine");  JSonObject deadLine= new JSonObject(jsDeadLine);  String seconds = deadLine.getString("seconds");  String minutes = deadLine.getString("minutes");  String hours = deadLine.getString("hours");  String mday = deadLine.getString("mday");  String wday = deadLine.getString("wday");  String mon = deadLine.getString("mon");  String year = deadLine.getString("year");  String yday = deadLine.getString("yday");  String weekday = deadLine.getString("weekday");  String month = deadLine.getString("month");  System.out.println("seconds:"+seconds);  System.out.println("minutes:"+minutes);  System.out.println("hours:"+hours);  System.out.println("unlockedStamp="+menuObject.getJSonObject(i)          .getString("unlockedStamp"));  unlockedStamp=menuObject.getJSonObject(i).getString("unlockedStamp");  JSonObject unlocked= new JSonObject(unlockedStamp);  String unlockedseconds = unlocked.getString("seconds");  String unlockedminutes = unlocked.getString("minutes");  String unlockedhours = unlocked.getString("hours");  String unlockedmday = unlocked.getString("mday");  String unlockedwday = unlocked.getString("wday");  String unlockedmon = unlocked.getString("mon");  String unlockedyear = unlocked.getString("year");  String unlockedyday = unlocked.getString("yday");  String unlockedweekday = unlocked.getString("weekday");  String unlockedmonth = unlocked.getString("month");  System.out.println("unlockedseconds:"+unlockedseconds);  System.out.println("unlockedminutes:"+unlockedminutes);  System.out.println("unlockedhours:"+unlockedhours);  System.out.println("description="+menuObject.getJSonObject(i).getString(          "description"));  System.out.println("id="+menuObject.getJSonObject(i)          .getString("id"));  System.out.println("dealurl="+menuObject.getJSonObject(i).getString(          "dealurl"));         }     } catch (Exception e) {         e.printStackTrace();     } }    } catch (Exception e) {        e.printStackTrace();    }    }


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/449339.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号