trans-am
2 years agoOccasional Contributor
Getting elements from json list to varable
Let's say I have following json response list stored in "response" variable
import groovy.json.JsonSlurper
def response = context.expand( '${GetResponse#response}' ).toString() // get response data to string
log.info(response) // print the data list
{"list": [{"status": "ACTIVE", "Number": 123, "Version": "1.12"}]}
Now I want to get e.g. status and put it to variable "currentStatus" and Number to "currentNumber". So how to do it? I tried few ways with JsonSlurper() but always getting "null" value
Thanks for confirming. It will be great help if you accept this as solution