JMeter JSON Extractor,提取字符串中一个键的所有值

bre*_*one 3 json jmeter extractor

使用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"
}]
Run Code Online (Sandbox Code Playgroud)

想要解析上面的响应,以便在JSON Extractor中将所有ID都放在一个字符串中,比如

3,1,6
Run Code Online (Sandbox Code Playgroud)

我的JSON Path表达式是这样的:

$..id
Run Code Online (Sandbox Code Playgroud)

但我只获得了第一个id为3,与$.[0].id 在BeanShell PostProcessor中检查结果的结果相同.如果我去http://jsonpath.com/ $ ..我确实给了我

[
  3,
  1,
  6
]
Run Code Online (Sandbox Code Playgroud)

Dmi*_*i T 5

如果您将JSON Extractor配置为:

JSON Extractor Concatenation

您将获得所需的值 ${foo_ALL}

JMeter JSON连接


我不认为使用Beanshell是检查JMeter变量值的最佳方法,我建议使用Debug Sampler,请参阅如何调试Apache JMeter脚本以获取更多详细信息.