如何解决勘误表 jmeter 提取器上 JMESpath 的不同行为
我试图在包含 Null 值的数组上提取最高值; jmeter 不这样做,有人知道为什么吗?
using: max(result[].data[].values[]) 在 https://jmespath.org/tutorial.html 处工作正常
ERROR o.a.j.e.j.j.JMESPathExtractor:在 JSON JMESPath Extractor 中处理 JSON 内容时出错,消息:调用“max”的参数类型无效:预期的数字或字符串数组但包含数组的数组
{
"result": [
{
"metricId": "count.server","data": [
{
"dimensions": [
"SERVICE_METHOD"
],"dimensionMap": {
"dt.entity.service_method": "SERVICE_METHOD"
},"values": [
null,null,1,4,null
]
}
]
}
]
}
解决方法
我不认为表达“工作正常”,因为它产生类似:
所以你需要:
- 摆脱这个嵌套的 JSON Array
- 去掉这些
const controller = new AbortController(); fetchTimeout( `https://en.wikipedia.org/w/api.php?action=parse&format=json&origin=*&page=${_planet}&prop=sections&disabletoc=1`,5000,{ signal: controller.signal } ) .then((response) => response.json()) .then((data) => { // const _index = data.parse.sections.find((one) => // one.line.toLowerCase().includes("internal") // ).index; // same codes from above // currently timeout error only works for first api request which is not what I want }) .catch((error) => { if (error.name === "AbortError") { alert("please check your connection"); } else { console.log(`error: ${error.name}`) } }); function fetchTimeout(url,ms,{ signal,...options } = {}) { const controller = new AbortController(); const promise = fetch(url,{ signal: controller.signal,...options }); if (signal) signal.addEventListener("abort",() => controller.abort()); const timeout = setTimeout(() => controller.abort(),ms); return promise.finally(() => clearTimeout(timeout)); }
条目
示例 JMESPath 查询类似于:
null
演示:
更多信息:The JMeter JSON JMESPath Extractor and Assertion: A Guide
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。