[JSON] Validating/Asserting JSON response with Jsonlurper

import groovy.json.JsonSlurper

def response = messageExchange.response.responseContent
log.info "response :   "+ response

def slurper = new JsonSlurper()
def json = slurper.parseText response
log.info "json :   "+ json

log.info "json size :   "+json.size()
assert json.SecId.size() == 6

log.info "The first json  :   "+json[0]

log.info "The first SecId  :   "+json[0].SecId
assert json[0].SecId  =="0P0000187J"

JsonSlurper (groovy 2.4.3 API)   :  http://docs.groovy-lang.org/latest/html/gapi/groovy/json/JsonSlurper.html

 [JSON] Validating/Asserting JSON response with Jsonlurper_第1张图片

[JSON] Validating/Asserting JSON response with Jsonlurper_第2张图片

[JSON] Validating/Asserting JSON response with Jsonlurper_第3张图片

[JSON] Validating/Asserting JSON response with Jsonlurper_第4张图片

你可能感兴趣的:(response)