我有一个来自 Web 服务的 JSON 响应项,如下所示:
[
{
"field1":"value",
"field2":"value2",
"field3":"value3",
"field4":"value4"
},
{
"field1":"value",
"field2":"value2",
"field3":"value3",
"field4":"value4"
},
...
]
在转换之前,我的响应字符串看起来很正常(像这样):
[{"field1":"value","field2":"value2","field3":"value3", "field4":"value4"},{...},...]
但是在我跑步之后def allData = new JsonSlurper().parseText(response)
然后记录allData
它似乎正在将我的对象转换为数组:
例子:
[["field1":"value","field2":"value2","field3":"value3", "field4":"value4"],[...],...]
有谁知道为什么会这样?
编辑:
进口:
import groovy.json.JsonSlurper