Extract json in array in Jmeter

How to extract json object name

from below json data

in Jmeter

[
:   {
:   :   "name":"x",
:   :   "age":"50",
:   :   "gender":"Female"
:   }
]

      

I do this $..name

in the JsonPath Extractor, which gives me this in a variable that I have extracted so that

name=["x"]

      

Is there a way I could just get name=x

without array format

Or is there a way that I can only extract x

from ["x"]

?

thank

+3


source to share


3 answers


you can use

 ${name_1} 

      



after getting the array with

$..name

      

+1


source


Using this in the post bean handler is handled

 String newName = vars.get("name"). replace([","").replace("]","").replace("\"","");
log.info("name is: " +newName);

      



which gives name is: x

+1


source


You need to get the name attribute from the first object in the array, so you need to change the JSON Path expression to look like$[0].name

Literature:

0


source







All Articles