gson json解析器:没有键的值

时间:2012-05-29 13:49:12

标签: java json gson

我想解析一个像这样的json结构:

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

如果count具有键“count”(例如),则一切正常。但关键是空白。是否有任何方式来映射此结构并手动只检索此值,或者我需要在没有gson的情况下自己解析所有这个json?

已更新

这是一个有效的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):  ..."
            }
        ]
    }
}

1 个答案:

答案 0 :(得分:2)

如果您要解析任意集合,请阅读Serializing and Deserializing Collection with Objects of Arbitrary Types并查看示例代码example code