【发布时间】:2018-12-04 11:58:42
【问题描述】:
我一直在尝试使用 GSON 从 JSON 获取所有预订的列表,但不断收到错误消息。难道我做错了什么?如果是,那么我应该如何解决这个问题?
我的尝试:
Gson gson = new Gson();
Wrapper reservations = gson.fromJson(response.toString(), Wrapper.class);
类:
class Wrapper{
Long id;
Long personId;
List<Long> SeatsIDs;
}
PS GSON 中是否有解决方案来摆脱所有“链接”?
{
"links": [
{
// a lot of stuff
}
],
"content": [
{
"id": 1,
"personID": 12335,
"seatsIDs": [
5,
7,
4
],
"links": [
{
// a lot of stuff
},
{
// a lot of stuff
}
]
},
{
"id": 2,
"personID": 77777,
"seatsIDs": [
1,
2,
3
],
"links": [
{
// a lot of stuff
},
{
// a lot of stuff
}
]
}
]
}
【问题讨论】:
-
你能解释一下你有什么错误吗?