Hi,
How do I extract a value for a node name that is dynamic. I am trying to get all of the values in a JSON response for a particular node name that is configurable and will change. For eg, in groovy script I am trying to do
for (i in 0 .. nodeCount-1)
{
def fieldName = "slurperresponse.Results." + filterField + "[" + i + "]"
log.info " Field Name " + fieldName
// Way I am trying to make it dynamic. The field name will vary
def responseFieldName = fieldName
log.info ( " ResponseFieldName " + responseFieldName)
// With hardcoded values that work.
responseFieldName = slurperresponse.Results.PartyName[0] ;
log.info ( " ResponseFieldName " + responseFieldName)
//log.info ( " Loop count " + i + " Value <" + responseFieldName + "> FilterField <" + filterField + "> \n")
if (!responseFieldName.equals(filterValue))
{
log.info(" Response Node count does not match that of \$filterParam value : Received Value: <" + responseFieldName + "> Expected : <" + filterValue + ">")
testRunner.fail( "Bad Response for filter" )
}
}
The o/p is below
- Tue Sep 01 13:35:22 CDT 2015:INFO: Field Name slurperresponse.Results.PartyName[0]
Not the value I want. I am not sure how to convert this to an object so that I can get the right value. This is a showing up as a string.
- Tue Sep 01 13:35:22 CDT 2015:INFO: ResponseFieldName slurperresponse.Results.PartyName[0]
The value I want
- Tue Sep 01 13:35:22 CDT 2015:INFO: ResponseFieldName DEMAR, MARK MD
Would really appreciate the help.