0

Response:

[
    {"msisdn":"85237009372","name":"Vicky","carrier":"AIRTEL"},
    {"msisdn":"85237009373","name":"Vicky1","carrier":"AIRTEL"}
]

I want to extract the all name from response and assign it to array/list?

Code:

import groovy.json.JsonSlurper

// Retrieve valid mptu Amounts from GET mptu-amounts response
context.responseContent = context.testCase.getTestStepByName("xxxx").getPropertyValue("r_responseContent")

try
{
  responseContentParsed = new JsonSlurper().parseText( context.responseContent )

  context.mptuValidAlias = responseContentParsed.name[0]
  log.info(context.mptuValidAlias)
}

It is retrieving the first row, name (i.e) vicky only.. i wanted to extract name of all rows and assign it to list.. How to do this?

4

1 回答 1

1

Change this line:

context.mptuValidAlias = responseContentParsed.name[0]

to this:

context.mptuValidAlias = responseContentParsed.name
于 2013-02-12T08:23:43.737 回答