阅读在android系统活动JSON数组我知道如何解析JSON对象像下面使用recyclerview和cardview
{
"users": [{
"id": 2,
"username": "user",
"full_name": "user full name",
"profilePicture": "/images/profileimage.png"
},
{
"id": 2,
"username": "user2",
"full_name": "user2 full name",
"profilePicture": "/images/profileimage2.png"
}
]
}
使用recyclerview和cardview这样
try {
JSONObject response = new JSONObject(result);
JSONArray users= response.optJSONArray("users");
feedsList = new ArrayList<>();
for (int i = 0; i < users.length(); i++) {
JSONObject user = users.optJSONObject(i);
FeedItem item = new FeedItem();
item.setTitle(user.optString("full_name"));
item.setThumbnail(user.optString("profilePicture"));
feedsList.add(item);
}
} catch (JSONException e) {
e.printStackTrace();
}
,我已经打电话JSON对象下面的JSON我想读在Android的活动
[
{
"id": 2,
"username": "user",
"full_name": "user full name",
"profilePicture": "/images/profileimage.png",
},
{
"id": 2,
"username": "user2",
"full_name": "user2 full name",
"profilePicture": "/images/profileimage2.png",
}
]
任何人都知道如何我可以读这种类型的JSON开始的[不是{能帮我
问题是什么?你说你可以解析JSON,但后来你说你不能? – Denny
@Knight请检查我的答案。 –
你的JSON是错误的在JSON LINT上检查它并检查我的答案@Denny –