Skip to content

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

Open
@5Orange

Description

@5Orange

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions