Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

[ {
   "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

3,1,6

My JSON Path expressions is like this:

$..id

But I got only the 1st id which is 3, the same result as $.[0].id Checking the result in a BeanShell PostProcessor. If I go to http://jsonpath.com/ $..id does give me

[
  3,
  1,
  6
]
like image 931
brewphone Avatar asked Dec 23 '22 18:12

brewphone


1 Answers

If you configure your JSON Extractor like:

JSON Extractor Concatenation

You will get the required value as ${foo_ALL}

JMeter JSON Concatenation


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.

like image 92
Dmitri T Avatar answered May 19 '23 05:05

Dmitri T