我正在尝试解析来自MongoDB云服务器的数据。从服务器返回的JSON数据如下:
[
{
"_id": {
"$oid": "4e78eb48737d445c00c8826b"
},
"message": "cmon",
"type": 1,
"loc": {
"longitude": -75.65530921666667,
"latitude": 41.407904566666666
},
"title": "test"
},
{
"_id": {
"$oid": "4e7923cb737d445c00c88289"
},
"message": "yo",
"type": 4,
"loc": {
"longitude": -75.65541383333333,
"latitude": 41.407908883333334
},
"title": "wtf"
},
{
"_id": {
"$oid": "4e79474f737d445c00c882b2"
},
"message": "hxnxjx",
"type": 4,
"loc": {
"longitude": -75.65555572509766,
"latitude": 41.41263961791992
},
"title": "test cell"
}
我遇到的问题是数据结构返回时没有给JSON对象数组命名。每个返回的对象都是一个“post”。但是如果没有JSON对象数组的名称,该如何使用GSON解析它呢?我想将这些“posts”放入一个类型为Post的ArrayList中。