php - 如何在 Android 中读取这种 json o/p?
问题描述
[
{
"hit": "1"
},
{
"SUM(hit)": "196290"
},
{
"COUNT(id)": "4010"
}
]
如何在android中读取这种json o/p
解决方案
//You can use below code for parsing this kind of jsonarray
String yourResponse;
JSONArray jsonarray = new JSONArray(yourResponse);
for (int i = 0; i < jsonarray.lenght(); i++){
JSONObject jsonobject = jsonarray.getJSONObject(i);
if(jsonobject.has("hit"){
String hit = jsonobject.getString("hit");
}
if(jsonobject.has("SUM(hit)"){
String sumHit = jsonobject.getString("SUM(hit)");
}
if(jsonobject.has("COUNT(id)"){
String countID = jsonobject.getString("COUNT(id)");
}
}
推荐阅读
- typescript - 如何在 NestJS 中配置 TypeORM 以使用 postgres 复制?
- javascript - Django3:动态生成可以在 HTML 页面中使用的 js
- python - 编码分类特征?
- python - Scrapy 的多个请求
- paypal - 如何使用 PayPal 订阅多个定期付款计划?
- python - 使用 for 循环与使用 .copy() 或 [:] 复制列表
- c++ - 删除的功能,不能将一条记录重写为另一条记录,对象
- xamarin.forms - 无法在 UWP 应用程序中发现蓝牙设备,但在 WPF 应用程序中工作
- react-native - 如何在 React Native 中的身份验证状态更改时更改路由
- python - PyCharm IDE:“import @”代码有效,但“from @import @”无效