我已经解析了它并查看了它的键集的 json 响应,如下所示。它只给了我 3 个键集。为什么它只制作 3 个键集的键值对?如何检索向下两个或多个级别的字段的值?
Json 看起来像这样(在content
变量中)
{
"seatbid":[
{
"bid":[
{
"id":"1",
"impid":"1",
"price":3.5999999046325684,
"nurl":"abc.com",
"adomain":[
"zagg.com",
"zagg.com"
],
"iurl":"abc.com",
"crid":"30364.s320x50m",
"h":0,
"w":0
}
],
"group":0
}
],
"cur":"USD",
"nbr":0
}
我解析并进行了这样的键集检查:
def RespSlurper = new JsonSlurper()
def RespJson = RespSlurper.parseText(content)
log.info(RespJson.keySet())
log.info(RespJson.values())
log.info(RespJson.get("seatbid"))
上面的回复log.info
是
Mon Jan 12 16:12:25 EST 2015:INFO:1
Mon Jan 12 16:12:25 EST 2015:INFO:[nbr, seatbid, cur]
Mon Jan 12 16:22:47 EST 2015:INFO:[0, [{group=0, bid=[{w=0, id=1, nurl=abc.com, price=3.5999999046325684, crid=30364.s320x50m, adomain=[zagg.com, zagg.com], impid=1, iurl=abc.com}]}], USD]
Mon Jan 12 16:22:47 EST 2015:INFO:[{group=0, bid=[{w=0, id=1, nurl=abc.com, price=3.5999999046325684, crid=30364.s320x50m, adomain=[zagg.com, zagg.com], impid=1, iurl=abc.com}]}]
我如何获取其他字段的值impid
?
log.info(RespJson.get("impid"))