jmeterjsonpathextractor

JMeter JSON Path Extractor with input variable


Is it possible to use input variables in the JSON Path Extractor expression?

I tried expression $.[${someInputVariable}].name, but it didn't work.

Data format:

[ 
{name=a}, 
{name=b}, 
{name=c}
]

If for example ${inputVariable} is set to 1, I would like the expression to return "b".

All the examples I found so far have hardcoded search values such as $.[1].name or $..[?(@.name == 'Smith')]


Solution

  • First you JSON is wrong, it should be:

     [{"name":"a"}, {"name":"b"},{"name":"c"}]
    

    To extract what you want just use the __eval function:

     ${__eval($.[${someInputVariable}].name)}