0

我从 UI 得到了 json[]。我必须将其转换为 Json 对象,如何使用gson. 接收到的对象是这样的:

 [{"name":"name","value":"value"},{"name":"first","value":"100"},{"name":"hor","value":"95"},{"name":"conf","value":"95"}],[{"name":"vaRType","value":"INCRE"},{"name":"per","value":"100"},{"name":"hor","value":"95"},{"name":"conf","value":"95"}]

我用过JsonObject obj = new JsoParser().parse(jsonStrnig).getAsJsonObject(); ,但它会引发异常。

4

2 回答 2

3

因为它不是有效的 json 对象。

于 2012-11-06T08:53:44.873 回答
1

您的 JSON 应如下所示,因为目前它是无效的...

[
    [
        {
            "name": "name",
            "value": "value"
        },
        {
            "name": "first",
            "value": "100"
        },
        {
            "name": "hor",
            "value": "95"
        },
        {
            "name": "conf",
            "value": "95"
        }
    ],
    [
        {
            "name": "vaRType",
            "value": "INCRE"
        },
        {
            "name": "per",
            "value": "100"
        },
        {
            "name": "hor",
            "value": "95"
        },
        {
            "name": "conf",
            "value": "95"
        }
    ]
]
于 2012-11-06T09:18:53.837 回答