Skip to content

Filter with 2+ consecutive '&&' operators returns parsing error #24

@jarangutan

Description

@jarangutan

What is

Trying to do something like:

$.store.book[? @.category == "reference" && @.author == "Nigel Rees" && @.price == 8.95]

will throw out the error:

Error parsing jsonpath: unexpected '&' at position 70

What works

Multiple || operators works, a single || with a && works, but two && back to back blows up. But, you can wrap the second condition in a parenthesis to get it to work:

$.store.book[? @.category == "reference" && (@.author == "Nigel Rees" && @.price == 8.95)]

If you need more && conditions, you would need to do something like this:

$.store.book[? @.category == "reference" && (@.author == "Nigel Rees" && (@.price == 8.95 && @.title == "Sayings of the Century")) ]

What do

I can't tell if this is intentional or not since the RFC doesn't really give much on the && operator. There also isn't a test for this in the compliance test suite.

I'm thinking of cracking open an issue on the compliance test suite to get feedback and add the test if it makes sense.

Would you be cool with me trying my hand at the PR if it turns out the test was missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions