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

如何从Android中的URL解析多个JSON对象和数组?我在这个例子中使用我想要的例子,

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

如何从Android中的URL解析多个JSON对象和数组?我在这个例子中使用我想要的例子,

响应

JSonObject JObject = new JSonObject(response);      String getting_data = JObject.getstring("getting data");    String Todays= JObject.getstring("Todays");    JsonArray results =JObject.getjsonarray("results");    for(int i = 0 ; i < results.length(); i++){     JsonObject resultsobject =results.getjsonobject(i);    JsonArray worldpopulation =resultsobject.getjsonarray("worldpopulation");         for(int j = 0 ; j < worldpopulation.length(); j++){     JsonObject worldpopulationobject =worldpopulation.getjsonobject(j);     JsonObject emptyobject =worldpopulationobject.getjsonobject("");         String rank=emptyobject .getstring("rank");         String population=emptyobject .getstring("population");         JsonArray flagarray =countrypulation.getjsonarray(flag);        for(int n = 0 ; n < flagarray.length(); n++){        JsonObject flagarrayobject =flag1array.getjsonobject(n);        String flag=flag1arrayobject .getstring("flag");         }     JsonObject populationobject =worldpopulationobject.getjsonobject("population");         JsonArray emptyarray =JObject.getjsonarray("");    for(int k = 0 ; k < emptyarray.length(); k++){        JsonObject emptyarrayobject =emptyarray.getjsonobject(k);        JsonObject countrypulation=emptyarrayobject.getjsonobject("countrypulation");         String rank1=countrypulation .getstring("rank");         String country=countrypulation .getstring("country");         String population1=countrypulation .getstring("population");        JsonArray flag1array =countrypulation.getjsonarray(flag);        for(int m = 0 ; m < flag1array.length(); m++){        JsonObject flag1arrayobject =flag1array.getjsonobject(m);        String flag1=flag1arrayobject .getstring("flag");         }    }    }    }


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

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

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