I want to change the value of 'action' to "1".
Currently my code is as follows.
import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
def slurped = new JsonSlurper().parseText(vars.get("reqApproval"))
def builder = new JsonBuilder(slurped)
builder.content.action = "1"
vars.put("reqApproval", builder.toPrettyString())
The JSON array is like so (excess variables removed)
{
"requisitionApprovals": [
{
"action": ""
}
]
}
I'm not sure what the syntax is to access the action field inside the requisitionApprovals array.
My current solution just adds a variable 'action' outside the array, but I need to access the variable inside the array.
I've tried all the below and they don't work
builder.content.requisitionApprovals.action = "1"
builder.content.requisitionApprovals.[0].action = "1"
builder.content.requisitionApprovals[0].action = "1"