0
votes

How to filter by boolean value in JSONPath expression?

I'm using this site which fails to validate my expression and I am looking for an explanation why: https://jsonpath.curiousconcept.com/#

My JSON is

{
  "whatever" : {
    "best" : {
      "reward" : "true"
    } 
  } 
}

And my expression, which fails to match (in Gatling, not validator site), is either of these:

$.whatever.best[?(@.reward=='true')]
$.whatever.best[?(@.reward==true)]

This expression works fine:

$.whatever.best.reward

And strangely, this works:

$..*[?(@.reward==true)]

What is wrong? Please no guesses. I provided the site in order to verify your answer.

The instructions here did not help me: https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html#filters

1

1 Answers

0
votes

The implementation used in the online evaluator you're mentioning is broken.

The $.whatever.best[?(@.reward=='true')] expression is correct as "true" is not a JSON boolean value but a String one. Gatling implementation is correct and works as expected.