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

map function not honouring Option.SUPPRESS_EXCEPTIONS #612

Closed
ghost opened this issue May 1, 2020 · 2 comments
Closed

map function not honouring Option.SUPPRESS_EXCEPTIONS #612

ghost opened this issue May 1, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented May 1, 2020

Hi,
DocumentContext.map() is not honouring Option.SUPPRESS_EXCEPTIONS, while DocumentContext.read() is working fine

sample test -

    @Test
    public void test() {
        Configuration config = Configuration.builder()
                .options(Option.SUPPRESS_EXCEPTIONS)
                .build();
        String json = "{\"1\":{\"2\":null}}";
        DocumentContext documentContext = JsonPath.using(config).parse(json);
        JsonPath query = JsonPath.compile("$.1.2.a.b.c");
        Assert.assertNull(documentContext.read(query));
        try {
            documentContext.map(query, (object, configuration) -> object);
        } catch (Exception e) {
            fail("got exception: " + e);
        }
    }

which fails with message -

got exception: com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property ['a'] in path $['1']['2'] but found 'null'. This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
@CindyChow123
Copy link
Contributor

Hi @errorblade ,I would like to fix this bug.

@kallestenflo
Copy link
Contributor

Fixed by #711

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