简体   繁体   English

jmeter jsonpath表达式的数组长度

[英]jmeter jsonpath expression for length for the array

I have a jmeter test which should exit when the response array is null. 我有一个jmeter测试,当响应数组为null时应退出。 To test this, I'm accessing array and checking length in the beanshell assertion. 为了测试这一点,我正在访问数组并检查beanshell断言中的长度。 I have tried 我努力了

jsonpath Expression:$.x.length jsonpath表达式:$。x.length

where as in html response the array looks like {"x":[]}. 与html响应一样,该数组看起来像{“ x”:[]}。 I got "xtract failed com.jayway.jsonpath.PathNotFoundException: Path 'length' is being applied to an array. Arrays can not have attributes". 我收到“ xtract失败com.jayway.jsonpath.PathNotFoundException:路径'length'应用于数组。数组不能具有属性”。 How do I test if the array is null or array length null or zero. 如何测试数组是否为null或数组长度是否为null或零。 Thanks for the help. 谢谢您的帮助。

I think you are missing () on the function, ie: 我认为您在函数上缺少() ,即:

$.x.length()

See example here 在这里查看示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM