Jsonpath - subscript filters - negative operator causes test to crash

Hi all!

This post relates to Gatling’s handling of jsonpath.

Given the sample jsonpath (attached) which I took from Gatling’s JsonPath tests, the following jsonpath should give me the title of books which have an ISBN: $…book[?(@.isbn)].title

This is covered by the following test: gatling/JsonPathSpec.scala at main · gatling/gatling · GitHub

My understanding is that to find books WITHOUT isbn, we should just need to include a negative operator to the jsonpath - e.g. $…book[?(!@.isbn)].title

I can’t see any tests for this particular scenario. I’ve run the sample json through the online checker at jsonpath.com, and adding the negative operator works fine.

When I try to do the same in a Gatling test, the test crashes with the message “extraction crashed: end of input expected”. Note - the same jsonpath works fine if I remove the negative operator.

Given the sample json, I wouldn’t really want to have to write code to extract the full list, as well as a list containing isbn, and then remove one from the other - although this may be a workaround, it’s not ideal.

Thanks in advance!


sample.json (837 Bytes)

Note - I’m using Gatling 3.3.

Hi Barry,

Please read: https://gatling.io/2019/07/31/introducing-jmespath-support/
and use JMesPath.

Hi Stéphane,

Thank you, this is very helpful. It shows that it’s been a while since I’ve had the opportunity to work with Gatling! I’m glad you’ve already tackled this problem.

I was able to do what I need using JMesPath.


Glad it helped :slight_smile:

Sadly, I think JsonPath is a dead end, because of the lack of spec and the resulting discrepancy between implementations.
I know someone was trying to bring implementers to the table and come up with a spec but I don’t know if he succeeded.

I hope you’ll enjoy all the new goodies that made it into Gatling since you last used it :slight_smile: