JSON数据解析拿到其中的一个属性

Ryanly_z 2016-01-18 11:14:29
[{"numValue":1,"color":"","isUpload":"","otherType":3,"content":"住宅","type":2},{"numValue":2,"color":"","isUpload":"","otherType":3,"content":"别墅","type":2},{"numValue":3,"color":"","isUpload":"","otherType":3,"content":"写字楼","type":2},{"numValue":4,"color":"","isUpload":"","otherType":3,"content":"商铺","type":2},{"numValue":5,"color":"","isUpload":"","otherType":3,"content":"小产权","type":2},{"numValue":6,"color":"","isUpload":"","otherType":3,"content":"厂房","type":2},{"numValue":7,"color":"","isUpload":"","otherType":3,"content":"其他","type":2}]
这是我从自己缓存中那到的一段JSON数据,使用hiJosn校验如图:

现在我只想拿到其中的content属性并存到集合中要怎么做?
我使用如下代码转换失败,

try {
JSONObject jsonObject = new JSONObject(response.get(2).getData());
int jsonStr = jsonObject.length();
LogUtils.d("json", jsonStr+"");
for (int i = 0; i < jsonStr; i++) {
LogUtils.d("json", jsonObject.getString("content"));
}
} catch (JSONException e) {
LogUtils.d("json", "失败");
e.printStackTrace();
}

log只打印出了“失败”
求各路高手帮忙
...全文
128 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

80,490

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧