Unable to print list of all nodes including child nodes of a Json response using groovy script
Unable to print all node values and also child node values of a JSON response using groovy script in a Soap UI basic version
Below is my response
{
"lookupResponse": {"branches": {
"longitudeForMap": "-87.541405",
"latitudeForMap": "37.976581",
"foundWithinRadius": true,
"branch": [ {
"branchNumber": "123",
"location": "Balt-NE, IN",
"addressLine1": "test RD",
"addressLine2": "",
"city": "Baltimore",
"state": "IN",
"zip": "47715",
"branchManager": "tester, DAN",
"branchEmail": "test0435@gmail.com",
"phoneNumber": "(123) 479 - 6895",
"mloId": "98521",
"longitude": "-87.492300",
"latitude": "37.993700",
"distance": "2.920000",
"speaksSpanish": false,
"faxNumber": "(123) 473 - 5349",
}]
}},
"referenceNumber": "12345678",
"status": "SUCCESS"
}
Below is my Groovy code:
import groovy.json.*
def response = context.expand( '${'+strRequestName+'#Response}' )
def jsonResponse_Act = new JsonSlurper().parseText(response)
log.info "node lesngth is "+ jsonResponse_Act.size()
for(int nodeid=0 ; nodeid<int_nodelength;nodeid++)
{
//Getting error at this statement
log.info jsonResponse_Act[nodeid]
}
Tried this also
def nodes=jsonResponse_Act.lookupResponse
log.info "size "+ nodes.size()
log.info "value "+ nodes[0]