【发布时间】:2013-02-20 13:35:31
【问题描述】:
我正在尝试在 Android 应用程序上解析 ELGG resfull 网络服务 (http://elgg.pro.tn/services/api/rest/json/?method=system.api.list)。
我正在使用 GSON 库将 JSON 提要转换为 JAVA 对象,我为转换(映射)创建了所有需要的类
问题在于 JSON 格式(我无法更改):
{
"status":0,
"result":{
"auth.gettoken":{
"description":"This API call lets a user obtain a user authentication token which can be used for authenticating future API calls. Pass it as the parameter auth_token",
"function":"auth_gettoken",
"parameters":{
"username":{
"type":"string",
"required":true
},
"password":{
"type":"string",
"required":true
}
},
"call_method":"POST",
"require_api_auth":false,
"require_user_auth":false
},
"blog.delete_post":{
"description":"Read a blog post",
"function":"blog_delete_post",
"parameters":{
"guid":{
"type":"string",
"required":true
},
"username":{
"type":"string",
"required":true
}
},
"call_method":"POST",
"require_api_auth":true,
"require_user_auth":false
}
}
}
这种格式的“结果”包含许多不具有相同名称的子项(即使它们具有我称为“apiMethod”的相同结构),GSON 尝试将其解析为分离的对象,但我想要的是他将所有“结果”子项解析为“apiMethod”对象。
【问题讨论】:
标签: java android json parsing gson