Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incorrect filtering? #72

Open
DazzaL opened this issue Mar 26, 2023 · 1 comment
Open

incorrect filtering? #72

DazzaL opened this issue Mar 26, 2023 · 1 comment

Comments

@DazzaL
Copy link

DazzaL commented Mar 26, 2023

take a sample JSON document with no arrays in it:

{
    "a": {
        "ver": "1.0.0"
    },
    "m": {
        "attr1": "test1",
        "attr2": "test2"
    },
    "d": "my document"
}

if i want to return the "m" node if say attr1 = test1 then i can do this:
$.[?(@.attr1 == "test1")]
which results in this seen:

[
  {
    "attr1": "test1",
    "attr2": "test2"
  }
]

this is in disagreement to the Java jayway library which when given:

        var json = JsonPath.parse("""
{
    "a": {
        "ver": "1.0.0"
    },
    "m": {
        "attr1": "test1",
        "attr2": "test2"
    },
    "d": "my document"
}
""");
        System.out.println(json.read("$.[?(@.attr1 == \"test1\")]").toString());
    }

will result in []. Jaway wants the expression to be: $.m[?(@.attr1 == \"test1\")] and if that is given, this will be returned:
[{"attr1":"test1","attr2":"test2"}]

if I use $.m[?(@.attr1 == \"test1\")] in the jsonpath.com implementation though, No match is returned

is one of these implementations incorrect?

@ashphy
Copy link
Owner

ashphy commented Mar 30, 2023

It is incorrect behavior compared to the internet-draft of JSONPath.

However, this site uses jsonpath-plus as a parser that is not actively maintained.
There is no alternative implements in nodejs, so I plan to provide it, but it will take a long time.

If you want to fix this issue, please report to the jsonpath-plus repository instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants