How do I extract the json object name
from the below json data
in Jmeter
[
: {
: : "name":"x",
: : "age":"50",
: : "gender":"Female"
: }
]
I am doing this $..name
in the JsonPath Extractor which is giving me this in the variable I extracted to
name=["x"]
Is there a way I could just get name=x
without the array format
Or is there a way I can extract just the x
from ["x"]
?
Thanks
Using this in a bean shell post processor worked
String newName = vars.get("name"). replace([","").replace("]","").replace("\"","");
log.info("name is: " +newName);
which gives name is: x
You need to get name attribute from the first object in the array therefore you need to amend your JSON Path expression to look like $[0].name
References:
You may use
${name_1}
after getting the array with
$..name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.