Pra*_*ash 5 groovy json soapui
我试图在TxnType模拟来自 SOAPUI 的响应时从 json 请求中获取值。我想根据TxnType.
{
"Request": {
"UserId": "user",
"TxnType": "fetch"
}
}
Run Code Online (Sandbox Code Playgroud)
这是使用固定 json获取请求值的 groovy 脚本
def json = """{
"Request": {
"UserId": "user",
"TxnType": "fetch"
}
}"""
def transactionType = new groovy.json.JsonSlurper().parseText(json).Request.TxnType
log.info "TxnType is : ${transactionType}"
Run Code Online (Sandbox Code Playgroud)
您可以快速尝试Demo
如果你想在模拟脚本中使用动态json,那么你可以使用下面的模拟脚本调度程序
def transactionType = new groovy.json.JsonSlurper().parseText(mockRequest.requestContent).Request.TxnType
log.info "TxnType is : ${transactionType}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4693 次 |
| 最近记录: |