[英]How to extract the Json values in jmeter using regular expression extractor?
[英]JMeter JSON Extractor, extract all values of one key in a string
使用Apache JMeter ver 3.2 r1790745(最新版本)测试JSON Web服务,响应如下:
[ {
"id" : 3,
"description" : "Back",
"name" : "back"
}, {
"id" : 1,
"description" : "Front",
"name" : "front"
}, {
"id" : 6,
"description" : "Left",
"name" : "left"
}]
想要解析上面的响应,以便在JSON Extractor中将所有ID都放在一个字符串中,比如
3,1,6
我的JSON Path表达式是这样的:
$..id
但我得到的第一个id是3,结果与$.[0].id
相同$.[0].id
在BeanShell PostProcessor中检查结果。 如果我去http://jsonpath.com/ $ ..我确实给了我
[
3,
1,
6
]
如果您将JSON Extractor配置为:
您将获得所需的值${foo_ALL}
我不认为使用Beanshell是检查JMeter变量值的最佳方法,我建议使用Debug Sampler ,请参阅如何调试Apache JMeter脚本以获取更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.