Reputation: 33
I have a json response. I am using json assertion where in one of the keys I have a big array. I pass Json path as $.value.page[9999].hash. Now I want to have a variable value instead of 9999. How can I use variable instead of 9999. I tried to use variable generated in beanshell post processor. But I failed. Is there any solution to this?
Upvotes: 1
Views: 388
Reputation: 168072
You can use __V() function for this
The V (variable) function returns the result of evaluating a variable name expression. This can be used to evaluate nested variable references (which are not currently supported).
For example, if one has variables A1,A2 and N=1:
${A1}
- works OK
${A${N}}
- does not work (nested variable reference)
${__V(A${N})}
- works OK.A${N}
becomesA1
, and the__V
function returns the value ofA1
So you can come up with something like:
${__V($.value.page.[${page}].hash)}
Demo:
More information: Here’s What to Do to Combine Multiple JMeter Variables
Upvotes: 2
Reputation: 1991
Try eval() and evalVar() functions to extract what you want:
${__eval($.value.page[${index}].hash)}
Upvotes: 0