[英]JMeter JSON Extractor, extract all values of one key in a string
Using Apache JMeter ver 3.2 r1790745 (the latest) to test a JSON Web Service, the response is like: 使用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"
}]
Want to parse the above response to get all ids in one string in JSON Extractor, like 想要解析上面的响应,以便在JSON Extractor中将所有ID都放在一个字符串中,比如
3,1,6
My JSON Path expressions is like this: 我的JSON Path表达式是这样的:
$..id
But I got only the 1st id which is 3, the same result as $.[0].id
Checking the result in a BeanShell PostProcessor. 但我得到的第一个id是3,结果与$.[0].id
相同$.[0].id
在BeanShell PostProcessor中检查结果。 If I go to http://jsonpath.com/ $..id does give me 如果我去http://jsonpath.com/ $ ..我确实给了我
[
3,
1,
6
]
If you configure your JSON Extractor like: 如果您将JSON Extractor配置为:
You will get the required value as ${foo_ALL}
您将获得所需的值${foo_ALL}
I don't think using Beanshell is the best way to check JMeter Variable value, going forward I would suggest using Debug Sampler instead, see How to Debug your Apache JMeter Script for more details. 我不认为使用Beanshell是检查JMeter变量值的最佳方法,我建议使用Debug Sampler ,请参阅如何调试Apache JMeter脚本以获取更多详细信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.