【发布时间】:2015-09-08 07:25:33
【问题描述】:
如何使用 gson 解析 json?我有一个包含多种对象类型的 json 数组,我不知道我需要创建什么样的对象来保存这个结构。我无法更改 json 数据格式(我不控制服务器)。 我可以使用gson或其他库解析这个json数组吗,我该怎么做?
这是json代码块:
[
{
"type": 1,
"object": {
"title1": "title1",
"title2": "title2"
}
},
{
"type": 2,
"object": [
"string",
"string",
"string"
]
},
{
"type": 3,
"object": [
{
"url": "url",
"text": "text",
"width": 600,
"height": 600
},
{
"url": "url",
"text": "text",
"width": 600,
"height": 600
}
]
},
{
"type": 4,
"object": {
"id": 337203,
"type": 1,
"city": "1"
}
}
]
【问题讨论】:
-
嗨!您阅读并尝试过我的答案了吗?