0

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


  • gatlingVersion: 3.13.5
  • scalaVersion: 2.13.16
asked Jun 6, 2025 at 19:31

1 Answer 1

1

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`]

answered Jun 7, 2025 at 4:42
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.