spark85 / json-path

Automatically exported from code.google.com/p/json-path
0 stars 0 forks source link

Absent field inconsistency #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
With JSON {"a": {}} path $.a.x evaluates to null under version 0.9.1. It did 
result to an InvalidPathException under version 0.8.1. Path $.a.x.y results to 
an InvalidPathException under both versions.

Original issue reported on code.google.com by pascal@quies.net on 10 Jun 2014 at 3:11

GoogleCodeExporter commented 9 years ago
Can I get an update for this issue? Is the behavior change intentional or 
should we consider the current state as a bug?

Original comment by pascal@quies.net on 7 Jul 2014 at 2:07

GoogleCodeExporter commented 9 years ago
This is a bug! It's fixed in upcoming release. 

If you need <null> to be returned you must do like this

        String json = "{\"a\": {}}";

        Configuration configuration = Configuration.defaultConfiguration().options(Option.SUPPRESS_EXCEPTIONS);
        Assertions.assertThat(JsonPath.using(configuration).parse(json).read("a.x")).isNull();

Original comment by kalle.st...@gmail.com on 4 Aug 2014 at 10:29