我正在从REST API获得响应以下,但发现从接收到的响应中提取标签值并将其分配给变量以稍后在脚本中使用它很困难。
这是响应:
const date= currentitem.date;
我能够获得{
"result": "SUCCESS","rawAttr": "[{\"attributes\":[{\"name\":\"resourceid\",\"value\":\"7A7Q123456\"},{\"name\":\"physicalid\",{\"name\":\"dsw:label\",\"value\":\"MY Product00004285\"},{\"name\":\"dsw:created\",\"value\":\"2019-11-06T08:39:39Z\"}]}]","physicalid": "7A7Q123456","contextPath": "/path","id": "7A7Q123456","message": null
}
和response.id
,这对验证很有帮助,但是我却无法获得response.result
的{{1}} dsw:label
当我执行value
时,无论是数组还是字符串,我都得到以下值,我感到困惑。好像是一个字符串。
MY Product00004285
使用下面的JSON Path表达式在JMeter JSON Extractor中提取标签非常容易
def Arr = response.rawAttr