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

SUPRESS EXCEPTION is not working after upgrade version 2.6.0 to 2.7.0 (or higher version) #908

Open
5Orange opened this issue Mar 24, 2023 · 0 comments

Comments

@5Orange
Copy link

5Orange commented Mar 24, 2023

I'm trying to suppress all the exceptions when evaluating a JSON path. but when I upgrade the JSON path lib to 2.7, it seems like it is not working as expected.
For example:

var node = objectMapper.readTree("{\"test\" :  null}");

    JsonPath.using(Configuration.builder()
        .options(Option.SUPPRESS_EXCEPTIONS).build())
        .parse(node.toString())
        .read("$.test[?(@ != null)]");

we got an exception thrown.

Filter: [?] can not be applied to primitives. Current context is: null
com.jayway.jsonpath.InvalidPathException: Filter: [?] can not be applied to primitives. Current context is: null

when i remove a toString() method, it return an empty array.


but if we remove a toString() method and try with another path(example below), it return null

var node = objectMapper.readTree("{\"test\" : \"value response\" }");

  JsonPath.using(Configuration.builder()
      .options(Option.SUPPRESS_EXCEPTIONS).build())
      .parse(node)
      .read("$.test");

expected : "value response"
actual : NullNode

@5Orange 5Orange changed the title SUPRESS EXCEPTION is not working after upgrade version 2.6.0 to 2.7.0 SUPRESS EXCEPTION is not working after upgrade version 2.6.0 to 2.7.0 (or higher version) Mar 29, 2023
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

1 participant