简体   繁体   中英

jmeter jsonpath expression for length for the array

I have a jmeter test which should exit when the response array is null. To test this, I'm accessing array and checking length in the beanshell assertion. I have tried

jsonpath Expression:$.x.length

where as in html response the array looks like {"x":[]}. I got "xtract failed com.jayway.jsonpath.PathNotFoundException: Path 'length' is being applied to an array. Arrays can not have attributes". How do I test if the array is null or array length null or zero. Thanks for the help.

I think you are missing () on the function, ie:

$.x.length()

See example here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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