我看不出我的 JSON 有什么问题,我收到无法将其转换为 JSONObject 的错误。我在论坛上搜索,但我找不到答案。
代码(解析):
JSONObject json = new JSONObject(result.toString().replace("\\", " "));
JSONArray jArray = json.getJSONArray("timetable");
for(int i = 0; i < jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
String class_school = json_data.getString("class");
String teacher = json_data.getString("teacher");
String subject = json_data.getString("subject");
String room = json_data.getString("room");
timetList.add(new TimeTable(subject, class_school + " " + teacher + " " + " " + room));
}
JSON:
{"timetable":[{"teacher":"Woh","subject":"BVH","room":"017","change":"no"},{"teacher":"Rrl","subject":"BI","room":"045","change":"no"},{"teacher":"Ajg","subject":"WI","room":"019","change":"no"},{"teacher":"Sgh","subject":"NE","room":"119","change":"no"},{"teacher":"Rom","subject":"FA","room":"116","change":"no"},{"teacher":"Her","subject":"GS","room":"127","change":"no"},"free","free"]}
日志猫:
03-29 15:06:11.356: E/error(822): Value free at 6 of type java.lang.String cannot be converted to JSONObject