从url android获取json中的数据

时间:2016-07-25 09:42:19

标签: android json parsing

我想将数据输入自定义字段:

what I want - 1

what I want - 2

我使用以下代码获取有效类别的数据:

List<MusicModel.category> cateList = new ArrayList<>();
for(int j = 0; j < finalobject.getJSONArray("categories").length(); j++ )
{
     MusicModel.category cate = new MusicModel.category();
     cate.setCateTitle(finalobject.getJSONArray("categories").getJSONObject(j).getString("title"));
     cateList.add(cate);
}
musicModel.setListCategory(cateList);

1 个答案:

答案 0 :(得分:0)

参考吹码:

JSONObject responseObject = new JSONObject(reponseData);
JSONObject postObject = responseObject.optJSONObject("post");
if(null != postObject) {
 JSONObject customFields = postObject.optJSONObject("custom_fields");
 JSONArray postViewCount = customObject.optJSONArray("post_view_count");
 JSONObject postCountObject = postViewCount.get(0);
 String postCount = postCountObject.toString();
}