我需要从我的 json 响应中提取最后一个元素,我正在使用 json 后处理器。
json 路径 -
$.self[(@.length-1)].cashCardId
使用此路径后,我收到此错误 -
例外:无法解析从位置 6 开始的标记。应为 ?、'、0-9、*
经历错误后,我尝试了这个 jsonpath,但它抛出“NO MATCH”
$.self['(@.length-1)'].cashCardId
但是当我在在线评估器中评估我的 jsonPath 时,它工作正常。看起来 jmeter 源代码中存在任何类型的错误,或者可能是我产生了一些语法错误。
{
"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"
}
]
}