Forum Discussion

tsjakamaka's avatar
tsjakamaka
Occasional Contributor
5 years ago

Getting data out of json response

Hi,   As result of a GET call of REST service, I have following JSON response.   { "result": [ { "role": "ADMIN", "relationNumber": 8046017, "individual": { "firstName": "aaaa", "lastName"...
  • nmrao's avatar
    5 years ago

    Have a script with following snippet:

     

    //assign the response for jsonString Variable
    def jsonString = 
    
    def individualViewer = new groovy.json.JsonSlurper().parseText(jsonString).result.find{it.role == 'VIEWER'}.individual
    log.info "first name: ${individualViewer.firstName}"
    log.info "last name: ${individualViewer.lastName}"

     

    You can test it online

    https://ideone.com/yJSNYZ