6

我想解析这样的json结构:

{"response":
    {
    "arr1":[count,{...}],
    "arr2":[count,{...}]
    }
}

如果 count 有键“count”(例如),一切都很好。但是钥匙是空白的。有没有办法映射这个结构并手动检索这个值,或者我需要自己解析所有这些 json 而没有 gson ?

更新

这是一个有效的 json(通过http://jsonlint.com/检查)

{
    "response": {
        "arr1": [
            615,
            {
                "body": "hi",
                "title": "Re(2):  ..."
            },
            {
                "body": "hello",
                "title": "Re(23):  ..."
            }
        ],
        "arr2": [
            132,
            {
                "body": "hi",
                "title": "Re(2):  ..."
            },
            {
                "body": "hello",
                "title": "Re(23):  ..."
            }
        ]
    }
}
4

1 回答 1

3

如果你想解析任意集合,你应该阅读Serializing and Deserializing Collection with Objects of Arbitrary Types并查看示例代码示例代码

于 2012-05-30T09:30:45.990 回答