Thursday, 15 May 2014

How to assign values to array using groovy? -



How to assign values to array using groovy? -

response:

[ {"msisdn":"85237009372","name":"vicky","carrier":"airtel"}, {"msisdn":"85237009373","name":"vicky1","carrier":"airtel"} ]

i want extract name response , assign array/list?

code:

import groovy.json.jsonslurper // retrieve valid mptu amounts mptu-amounts response context.responsecontent = context.testcase.getteststepbyname("xxxx").getpropertyvalue("r_responsecontent") seek { responsecontentparsed = new jsonslurper().parsetext( context.responsecontent ) context.mptuvalidalias = responsecontentparsed.name[0] log.info(context.mptuvalidalias) }

it retrieving first row, name (i.e) vicky only.. wanted extract name of rows , assign list.. how this?

change line:

context.mptuvalidalias = responsecontentparsed.name[0]

to this:

context.mptuvalidalias = responsecontentparsed.name

groovy

No comments:

Post a Comment