在 SoapUI 中根据子值获取父值
Get a parent value based on child value in SoapUI
在响应 Json 中,获取如图所示的项目数组列表。
你在题目中看到的不是xml,而是一个json
字符串。所以,xpath
不起作用。
对于您的请求测试步骤,您可以添加 Script Assertion
,如下所示:
//Check the response
assert context.response, 'Response is empty or null'
//Expected subscription id, change it if needed
def expectedSubscriptionId = '2c92c0f95ae1445b015af2320235689f'
def parsedJson = new groovy.json.JsonSlurper().parseText(json)
def ids = [] as Set
parsedJson.each { item ->
item.amendments.each { amendment ->
if (amendment.subscriptionId == expectedSubscriptionId ) {
ids << item.id
}
}
}
assert ids.size(), "id's are not found in the response for matching subscription"
log.info "Matching id's are : ${ids}"
您可以快速在线尝试Demo
在响应 Json 中,获取如图所示的项目数组列表。
你在题目中看到的不是xml,而是一个json
字符串。所以,xpath
不起作用。
对于您的请求测试步骤,您可以添加 Script Assertion
,如下所示:
//Check the response
assert context.response, 'Response is empty or null'
//Expected subscription id, change it if needed
def expectedSubscriptionId = '2c92c0f95ae1445b015af2320235689f'
def parsedJson = new groovy.json.JsonSlurper().parseText(json)
def ids = [] as Set
parsedJson.each { item ->
item.amendments.each { amendment ->
if (amendment.subscriptionId == expectedSubscriptionId ) {
ids << item.id
}
}
}
assert ids.size(), "id's are not found in the response for matching subscription"
log.info "Matching id's are : ${ids}"
您可以快速在线尝试Demo