1

JSONPath filter only returns a result if the object is an array.

I have this json string:

{
  "books": {
    "author": "https://tpp-ob.com/callback",
    "price": "SandboxASPSP1"
  },
  "format": [
    "paper"
  ],
  "onSaleSince": "2019-01-17"
}

To test json path queries I use https://jsonpath.herokuapp.com/

When I write query like:

$.format[?(@ == 'paper')]

It works just fine.

But when I try to filter non-array element:

$.onSaleSince[?(@ == '2019-01-17')]

It doesn't work.

So my question is can I do something to filter non-array element?

Dagua
  • 51
  • 4

0 Answers0