【发布时间】:2014-05-02 09:15:48
【问题描述】:
我有一个带有动态键值的 JSON。例如:
"location_id": {
"0": 0,
"1": 1,
"2404": "Section 9 Shah Alam - 3.085376,101.522716",
"272": "Bukit Jelutong - 3.103953,101.527704",
"545": "Giant Shah Alam - 3.084166,101.549152",
...
}
通常,我会对固定键值做的是在 POJO 类中定义它,如下所示:
json:
"location_id": {
"id" : "hehe",
"name": "herpderp",
"location": "Section 9 Shah Alam - 3.085376,101.522716",
...
}
POJO 将如下所示:
private String id;
private String name;
private String location;
...
并且通过使用GsonRequest,它会将JSON解析为POJO。
但是,如何反序列化具有动态键值的 JSON?
【问题讨论】:
标签: android json gson android-volley