Why is Gatling failing on a valid jsonpath?

旧巷老猫 提交于 2021-01-29 15:28:30

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!