Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract the parameter from Json Response Using Groovy?

Tags:

soapui

The below is my response..

{"activation":{"existing":false, "customer": new}}

Now when I use

testRunner.testCase.getTestStepByName("xxx").getPropertyValue("response")

The above script is extracting the response. Now I wanted to extract "customer" value.

How to do this?

Thanks

like image 595
ChanGan Avatar asked May 16 '13 10:05

ChanGan


1 Answers

import groovy.json.JsonSlurper

responseContent = testRunner.testCase.getTestStepByName("xxx").getPropertyValue("response")
slurperresponse = new JsonSlurper().parseText(responseContent)
log.info (slurperresponse.activation.customer)
like image 50
ChanGan Avatar answered Oct 16 '22 04:10

ChanGan