jsonjmeterextractor

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
]

Solution

  • 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.