Reputation: 43
Here i'm Facing problem with groovy script that.Want to extract the response data from the http request.When the Response data consisting of 200 as value then only extract that value_description and print value. So here is the response what i am getting
{"value":"200","value_description":"pass"}
and code is
def response = new groovy.json.JsonSlurper().parse("200".equals(prev.getResponseData()))
means is there any possible that if value is 200 and than only print value description.using groovy script please tell me with simple code.
Upvotes: 1
Views: 1792
Reputation: 171184
Not sure if this is what you mean, it's really hard to tell, but I think you mean:
import groovy.json.JsonSlurper
def response = new groovy.json.JsonSlurper().parseText(prev.responseData)
if (response.value == '200') {
println response.value_description
}
Upvotes: 2