Gau*_*pta 0 android json web-services
"你好,伙计们,
请检查这个Json的格式.
{"id": "293369****","owner": {
"name": "******",
"id": "*****"},name": "test event","start_time": "2012-05-18T02:00:00","end_time":"2012-05-18T05:00:00","privacy": "FRIENDS","updated_time": "2012-05-18T08:25:37+0000"}
Run Code Online (Sandbox Code Playgroud)
M使用此代码.我能够获取除所有者json数组之外的所有值.我想获取所有者数组的值.请建议我哪里出错了.
json = new JSONObject(responsedata);
Log.d(TAG, "name=" + responsedata);
facebookData = new Events();
JSONArray data=json.optJSONArray("owner");
Log.d(TAG, "Data length==" + data.length());
if (data.length() > 0) {
for (int i = 0; i < data.length(); i++) {
JSONObject jsonobj = data.getJSONObject(0);
Log.d(TAG, "owner Name="+jsonobj.getString("name"));
}
}
facebookData.setEventName(json.getString("name"));
facebookData.setEventId(json.getString("id"));
facebookData.setEventStartDate(json.getString("start_time"));
facebookData.setEventEndDate(json.getString("end_time"));
facebookData.setPrivacy(json.getString("privacy"));
facebookData.setUpdatedTime("updated_time");
Run Code Online (Sandbox Code Playgroud)
我无法获取所有者姓名和所有者的脸书ID.我的json解析器有一些问题.
请帮助我.
在此先感谢Gaurav Gupta
{
"id":"293369****",
"owner":{
"name":"******",
"id":"*****"
},
"name":"test event",
"start_time":"2012-05-18T02:00:00",
"end_time":"2012-05-18T05:00:00",
"privacy":"FRIENDS",
"updated_time":"2012-05-18T08:25:37+0000"
}
Run Code Online (Sandbox Code Playgroud)
作为{暗示的JSONObject和[暗示JsonArray.
我在上面的字符串中找不到任何JsonArray."owner"是JsonObject.
您必须修改代码,请参阅http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/
| 归档时间: |
|
| 查看次数: |
146 次 |
| 最近记录: |