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?

1 Answer 1

1

Change this line:

context.mptuValidAlias = responseContentParsed.name[0]

to this:

context.mptuValidAlias = responseContentParsed.name
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.