问题
I have the following .check on my returned body: (I changed the values for security reasons but the structure is the same)
.exec(http("Get ids")
.post("GetIds")
.body(ElFileBody("json/getIds.json")).asJson
.check(jsonPath("$...Types..[?(@.Type == 'web')].id").findAll.saveAs("IDLlist"))
But the transaction fails with "Gettting findAll.exists extraction crashed: end of input expected when trying to extract values from a returned body"
Gatling prints the body of the failed transaction, when I take the exact body that the transaction had just failed on to http://jsonpath.com/ and evaluate the jsonpath that had just failed, I get good results with no issues. This means that the returned body is correct and that the jsonpath is also correct. What is the issue then?
回答1:
Thanks to Stephane from the Gatling forum, I found that $..Files[?(@.Format == 'DASH_Web')].URL is correct works instead of the variation that I had.
Since http://jsonpath.com/ was able to extract the correct path using my original syntax, I think its important to note that Gatling jsonpath is much more conservative in its syntax.
回答2:
It seems your JSON path syntax is wrong --> "$...Types..[?(@.Type == 'web')].id"
Try using JSONPath Online Evaluator -- http://jsonpath.com/ to find correct json syntax
来源:https://stackoverflow.com/questions/58910079/why-is-gatling-failing-on-a-valid-jsonpath