【发布时间】:2021-02-08 04:43:22
【问题描述】:
我有一个项目是从json中检索数据,但是出来的数据只是最后一部分。几个论坛解释说压倒一切的价值。但我仍然不明白如何解决它,或者我在数组捕获上错了
JSONArray arrayMaps = jsonObject.getJSONArray("Maps");
for (int i = 0; i < arrayMaps.length(); i++){
Model us = new Model();
JSONObject c = arrayMaps.getJSONObject(i);
us.setTitle(c.getString("judul_maps"));
us.setUrl(c.getString("img_maps"));
us.setContent(c.getString("desk_maps"));
us.setDownloads(c.getString("donlot_maps"));
listMap.add(us);
}
listMap 是一个数组列表
这是我的 json
{
"Maps": [
{
"judul_maps": "Mario Bross Maps 1x",
"img_maps": "https://i.ytimg.com/vi/e8N7oPv_MCs/maxresdefault.jpg",
"desk_maps": "x1 Super Mario Bros MAPS-1 for Minecraft is a parkour map created by jaxot. About the story, Mario and the Princess are walking peacefully in the park.",
"donlot_maps": "https://archive.org/download/mariobross_maps/mariobross_maps.zip",
"judul_maps": "Mario Bross Maps 2x",
"img_maps": "https://i.ytimg.com/vi/iZ5dbVvprkQ/maxresdefault.jpg",
"desk_maps": "x2 Super Mario Bros MAPS-2 for Minecraft is a parkour map created by jaxot. About the story, Mario and the Princess are walking peacefully in the park.",
"donlot_maps": "https://matix.li/951a59821a86",
"judul_maps": "Mario Bross Maps 3",
"img_maps": "https://i.ytimg.com/vi/lbPvLzB8ifc/maxresdefault.jpg",
"desk_maps": "Super Mario Bros MAPS-3 for Minecraft is a parkour map created by jaxot. About the story, Mario and the Princess are walking peacefully in the park.",
"donlot_maps": "https://matix.li/bf6ce47f3b2e",
"judul_maps": "Mario Bross Maps 4",
"img_maps": "https://i.ytimg.com/vi/iKyfNrksGeA/maxresdefault.jpg",
"desk_maps": "Super Mario Bros MAPS-4 for Minecraft is a parkour map created by jaxot. About the story, Mario and the Princess are walking peacefully in the park.",
"donlot_maps": "https://matix.li/cf70364bac8a",
"judul_maps": "Mario Bross Maps 5",
"img_maps": "https://i.ytimg.com/vi/nMIW-BoKdU4/maxresdefault.jpg",
"desk_maps": "Super Mario Bros MAPS-5 for Minecraft is a parkour map created by jaxot. About the story, Mario and the Princess are walking peacefully in the park.",
"donlot_maps": "https://matix.li/5cca3c7f677e"
}
]
}
【问题讨论】:
-
您发布的 JSON 是无效的。它包含无效的键。