码迷,mamicode.com
首页 > Web开发 > 详细

[JSON] Validating/Asserting JSON response with Jsonlurper

时间:2015-06-18 13:01:41      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/MasterMonkInTemple/p/4585351.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!