Let's say GET /api/v1/elements
returns:
[
{
"id": 1,
"name": "Foo",
"totalChildren": 0
},
{
"id": 2,
"name": "Bar",
"totalChildren": 4
},
{
"id": 3,
"name": "Lala",
"totalChildren": 0
}
]
I want to get only the elements with totalChildren > 0
.
Why this works as expected:
.exec(http("Get List GT 0")
.get("/api/v1/elements")
.headers(authorizationHeader)
.asJson
.check(jsonPath("$[?(@.totalChildren > 0)]")
.ofType[Map[String, Any]]
.findAll
.saveAs("elements")))
but this one returns an empty Seq:
.exec(http("Get List GT 0")
.get("/api/v1/elements")
.headers(authorizationHeader)
.asJson
.check(jmesPath("[?totalChildren > '0']")
.ofType[Seq[Any]]
.saveAs("elements")))
I'm trying to use JMESPath instead of JSONPath as recommended in Gatling documentation
3.13.5
2.13.16
The specification and the examples in there clearly state that a number is a literal and hence must be wrapped with backticks and not quotes.
The JavaScript implementation that's used on the JMESPath website violates this specification and considers that a String and a number can be equal. This is a bug.
The Java implementation Gatling uses gets it right.
The correct expression is [?totalChildren > `0`]