how to validate data via xpath in json assertor
I have json data in below format and i want to verify that for perticluar source id"67678" amount is -100. i tried to give below path using json asserort and tried converting json to xml and use xpath but that did not work.
/root/item/Ancillary[Id/string()="67678"]/Transaction/detail/Amount
{
"Type": "Mas",
"Date": "2023-09-15",
"Ancillary": {
"Id": "67678"
},
"Transaction": {
"Type": "Order",
"OrderID": "908f2",
"StartDate": "2023-09-15 19:00:20.061539",
"detail": {
"Type": "Future",
"Amount": -100,
"Price": "81.26000000",
"Identifier": {
"Type": "Exchange",
}
},
{ "Type": "Mas", "Date": "2023-09-15", "Ancillary": { "Id": "6767887778" }, "Transaction": { "Type": "Order", "OrderID": "908f2", "StartDate": "2023-09-15 19:9", "detail": { "Type": "Future", "Amount": -300, "Price": "81.26000000", "Identifier": { "Type": "Exchange", } },]
Answers
-
This works just fine for me in the JSON Assertor:
/root/item[Ancillary/Id/text()="67678"]/Transaction/detail/Amount/string()
0 -
did you select value assertion option? or any other option as i could still see error saying not a valid xpath @banken_parasoft
0 -
did you select value assertion option
Yes, Value assertion or String assertion would work.
i could still see error saying not a valid xpath
The XPath is syntactically correct. Can you show the error?
0