我有来自 Facebook 的 JSON 响应,其结构如下:
{
"data": [
{
"id": "105458566194298_411506355589516",
"message": "...",
"type": "status",
"created_time": "2012-11-25T17:26:41+0000",
"updated_time": "2012-11-25T17:26:41+0000",
"comments": {
"count": 0
},
{
"id": "105458566194298_411506355589516",
"message": "...",
"type": "status",
"created_time": "2012-11-25T17:26:41+0000",
"updated_time": "2012-11-25T17:26:41+0000",
"comments": {
"count": 0
}
]
}
我正在尝试使用 Gson 库对其进行反序列化:
public class FacebookPost {
public String Message;
public String Created_time;
}
Gson gson = new GsonBuilder().create();
Type listType = new TypeToken<ArrayList<FacebookPost>>() {}.getType();
ArrayList<FacebookPost> userList = gson.fromJson(responseJsonString, listType);
"data": [ ]
如果响应不是包装在- 容器中,这显然会起作用。但是我如何告诉 gsondata
在 JSON 响应中查看呢?