We are using a JSR223 code to make an json object using below code,
def mandatory = new groovy.json.JsonSlurper().parse(prev.getResponseData()).Properties.Room.Extras.findAll { extra -> extra.IsMandatory }
def payload = []
mandatory.each { extra ->
def item = [:]
item.put('ExtraId', extra.ExtraId)
item.put('OptionId', extra.Options[0].OptionId)
item.put('ExpectedNetCost', extra.Options[0].NetCost)
payload.add(item)
}
vars.put('payload', new groovy.json.JsonBuilder([Extras: payload]).toPrettyString())
we are using ‘toPrettyString’ as well but still getting an extra pair of curly braces (at the start and end).
Can someone please help to remove this !
I have tried this link After updating json file with groovy, the file data contains extra curly brackets and “content” object
but solution doesn’t work for me.