我有以下回应:
{
"data": [
{
"name": "This is a test 123",
"start_time": "2013-12-02T18:00:00+0530",
"end_time": "2013-12-02T20:00:00+0530",
"location": "Mount Lavinia",
"id": "525447507473743",
"rsvp_status": "attending"
},
{
"name": "This is a test event",
"start_time": "2013-12-02T18:00:00+0530",
"end_time": "2013-12-02T20:00:00+0530",
"location": "Mount Lavinia",
"id": "560383743988530",
"rsvp_status": "attending"
},
}
],
我有以下代码来访问响应:
JSONObject jsonObj = new JSONObject(result);
JSONArray jsonArr = jsonObj.getJSONArray("data");
for(int i = 0; i < jsonArr .length(); i++)
{
JSONObject jsonArrObj = jsonArr.getJSONObject(i);
String id = jsonArrObj.getString("id");
String username = jsonArrObj.getString("name");
Log.w("event names are", username.toString());
}
我收到以下错误:
json.JSON.typeMismatch(JSON.java:100)
我搜索了一个解决方案,但找不到任何解决方案。