I need to extract the last element from my json response, i am using json post processor.
json Path -
$.self[(@.length-1)].cashCardId
After using this path, i got this error -
Exception: Could not parse token starting at position 6. Expected ?, ', 0-9, *
After going through the error, i tried this jsonpath, but it throw "NO MATCH"
$.self['(@.length-1)'].cashCardId
But when i evaluate my jsonPath in an online evaluator, it works fine. Looks like there is any kind of bug in jmeter source, or may be i am producing some syntactical error.
{
"gift": [
],
"self": [
{
"cashInitialAmount": 2000.0,
"serialNumber": "M79H3LSU",
"creationTime": 1563783465000,
"endDate": "2036-01-01",
"cardType": "ECARD",
"buyerId": 397,
"cashPendingAmount": 2000.0,
"cardSerial": "M79H3LSU",
"purchaseOrderId": 6123682,
"initialOffer": 0.0,
"customerId": 397,
"offerId": null,
"cashCardId": 188503,
"purchaseTime": 1563783465000,
"lastModified": 1563783465000,
"activationTime": 1563783465000,
"cardNumber": "M79H3LSU",
"cardStatus": "ACTIVE",
"startDate": "2019-07-22"
},
{
"cashInitialAmount": 2000.0,
"serialNumber": "2OI5U2UV",
"creationTime": 1563783382000,
"endDate": "2036-01-01",
"cardType": "ECARD",
"buyerId": 397,
"cashPendingAmount": 2000.0,
"cardSerial": "2OI5U2UV",
"purchaseOrderId": 6123680,
"initialOffer": 0.0,
"customerId": 397,
"offerId": null,
"cashCardId": 188502,
"purchaseTime": 1563783382000,
"lastModified": 1563783382000,
"activationTime": 1563783382000,
"cardNumber": "2OI5U2UV",
"cardStatus": "ACTIVE",
"startDate": "2019-07-22"
},
{
"cashInitialAmount": 2000.0,
"serialNumber": "S7EJDE77",
"creationTime": 1563794985000,
"endDate": "2036-01-01",
"cardType": "ECARD",
"buyerId": 397,
"cashPendingAmount": 2000.0,
"cardSerial": "S7EJDE77",
"purchaseOrderId": 6123723,
"initialOffer": 0.0,
"customerId": 397,
"offerId": null,
"cashCardId": 188511,
"purchaseTime": 1563794985000,
"lastModified": 1563794985000,
"activationTime": 1563794985000,
"cardNumber": "S7EJDE77",
"cardStatus": "ACTIVE",
"startDate": "2019-07-22"
}
]
}