i am testing the api and i have a request and it returns me a json response and by using the json extractor i have extracted the id from the json data and store it in a variable.
the http request configuration looks like this:
the sample of json array looks like given below:
[
{
"photoUrls": [
"string"
],
"name": "fish",
"id": 9223372016900012742,
"category": {
"name": "string",
"id": 0
},
"tags": [
{
"name": "string",
"id": 0
}
],
"status": "available"
},
{
"photoUrls": [
"string"
],
"name": "doggie",
"id": 9223372016900012743,
"category": {
"name": "string",
"id": 0
},
"tags": [
{
"name": "string",
"id": 0
}
],
"status": "available"
},
{
"photoUrls": [
"string"
],
"name": "fish",
"id": 9223372016900012750,
"category": {
"name": "string",
"id": 0
},
"tags": [
{
"name": "string",
"id": 0
}
],
"status": "available"
},
{
"photoUrls": [
"string"
],
"name": "fish",
"id": 9223372016900012795,
"category": {
"name": "string",
"id": 0
},
"tags": [
{
"name": "string",
"id": 0
}
],
}
]
i want to get the last value from the extracted data but everytime the extracted data has been changing could anyone can help me in this..
thanks in advance for the help..!!
It's not clear what "last value" you're looking for, but if you look at JSONPath Examples there is [-1]
operator which returns the last element in the JSON Array
See JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios article for more information and examples
If you extract all matches for some reason and want to use the last match for another reason you could use __V() function like
${__V(PET_ID_${PET_ID_matchNr},)}