Reputation: 524
we use jSON Path expression in JSON Extracter in like: $.store.book[0].title
can we use a JMeter variable instead? like: ${myexpression}
Upvotes: 0
Views: 901
Reputation: 2547
Yes you can do that. I am providing a sample test which uses CSV dataset config to pick up the JSON Path Expression. Also used variable in the JSON Extractor field. JSON Response :
{
"firstName": "John",
"lastName" : "doe",
"age" : 26,
"address" : {
"streetAddress": "naist street",
"city" : "Nara",
"postalCode" : "630-0192"
},
"phoneNumbers": [
{
"type" : "iPhone",
"number": "0123-4567-8888"
},
{
"type" : "home",
"number": "0123-4567-8910"
}
]
}
Path Expression: $.phoneNumbers[:1].type
which is in a CSV file.
CSV Data sest config:
JSON Extractor Setting:
Extracted value fed to the next request:
Check in View Results tree listener:
Upvotes: 1