我在数组中具有以下JSON,并且当我尝试为此JSON设置值时,脚本会通过,但未设置值:
{
"langauageCode": "en-US",
"Test": [{
"_modificationTypeCode": "added",
"allocationTypeCode": "3",
"code": "Test1"
}]
}
我的代码:
def jsonRequest = slurper.parseText(rawRequest)
def builder = new JsonBuilder(jsonRequest)
builder.content.Test.code[0] ='Test2' //Code value is not getting set to 'Test2'
log.info builder.toPrettyString()
我设置的值不正确吗?
答案 0 :(得分:2)
我假设<div class="timeline descending">
<div class="event">
Event 1
</div>
<div class="event">
Event 2
</div>
<div class="event open">
Event 3
</div>
<div class="event">
Event 4
</div>
<div class="event">
Event 5
</div>
<div class="event">
Event 6
</div>
</div>
是slurper
的实例。如果是这样,则根本不需要使用JsonSlurper
,因为JsonBuilder
返回sluper
的实例。所以:
Map