从JSON数组中提取数据

从JSON数组中提取数据,第1张

从JSON数组中提取数据

这是个主意

JSonObject root = new JSonObject(yourJsonString);JSonArray sportsArray = root.getJSonArray("sports");// now get the first element:JSonObject firstSport = sportsArray.getJSonObject(0);// and details of the first elementString name = firstSport.getString("name"); // basketballint id = firstSport.getInt("id"); // 40JSonArray leaguesArray = firstSport.getJSonArray("leagues");// and so on, you can process leaguesArray similarly

它应该可以工作(如果有编译错误,请随时投诉)



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5587147.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存