Skip to content

Commit

Permalink
Merge pull request #585 from Alanscut/readme
Browse files Browse the repository at this point in the history
update Configuration part in README
  • Loading branch information
kallestenflo committed May 18, 2020
2 parents 512a35c + 667f2d6 commit 8d49cc7
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ If you configure JsonPath to use `JacksonMappingProvider` or `GsonMappingProvide
Book book = JsonPath.parse(json).read("$.store.book[0]", Book.class);
```

To obtainin full generics type information, use TypeRef.
To obtain full generics type information, use TypeRef.

```java
TypeRef<List<String>> typeRef = new TypeRef<List<String>>() {};
Expand Down Expand Up @@ -395,10 +395,13 @@ This option configures JsonPath to return a list even when the path is `definite
```java
Configuration conf = Configuration.defaultConfiguration();

//Works fine
//ClassCastException thrown
List<String> genders0 = JsonPath.using(conf).parse(json).read("$[0]['gender']");
//PathNotFoundException thrown
List<String> genders1 = JsonPath.using(conf).parse(json).read("$[1]['gender']");

Configuration conf2 = conf.addOptions(Option.ALWAYS_RETURN_LIST);

//Works fine
List<String> genders0 = JsonPath.using(conf2).parse(json).read("$[0]['gender']");
```
**SUPPRESS_EXCEPTIONS**
<br/>
Expand All @@ -407,6 +410,21 @@ This option makes sure no exceptions are propagated from path evaluation. It fol
* If option `ALWAYS_RETURN_LIST` is present an empty list will be returned
* If option `ALWAYS_RETURN_LIST` is **NOT** present null returned

**REQUIRE_PROPERTIES**
</br>
This option configures JsonPath to require properties defined in path when an `indefinite` path is evaluated.

```java
Configuration conf = Configuration.defaultConfiguration();

//Works fine
List<String> genders = JsonPath.using(conf).parse(json).read("$[*]['gender']");

Configuration conf2 = conf.addOptions(Option.REQUIRE_PROPERTIES);

//PathNotFoundException thrown
List<String> genders = JsonPath.using(conf2).parse(json).read("$[*]['gender']");
```

### JsonProvider SPI

Expand Down

0 comments on commit 8d49cc7

Please sign in to comment.