Browse Source

Tweaking configuration examples with current API

pull/98/head
Marcin Mielnicki 10 years ago
parent
commit
51076180f7
  1. 12
      README.md

12
README.md

@ -308,16 +308,16 @@ This option makes JsonPath return null for missing leafs. Consider the following
Configuration conf = Configuration.defaultConfiguration();
//Works fine
String gender0 = JsonPath.using(conf).read(json, "$[0]['gender']");
String gender0 = JsonPath.using(conf).parse(json).read("$[0]['gender']");
//PathNotFoundException thrown
String gender1 = JsonPath.using(conf).read(json, "$[1]['gender']");
String gender1 = JsonPath.using(conf).parse(json).read("$[1]['gender']");
Configuration conf2 = conf.addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
//Works fine
String gender0 = JsonPath.using(conf2).read(json, "$[0]['gender']");
String gender0 = JsonPath.using(conf2).parse(json).read("$[0]['gender']");
//Works fine (null is returned)
String gender1 = JsonPath.using(conf2).read(json, "$[1]['gender']");
String gender1 = JsonPath.using(conf2).parse(json).read("$[1]['gender']");
```
**ALWAYS_RETURN_LIST**
@ -328,9 +328,9 @@ This option configures JsonPath to return a list even when the path is `definite
Configuration conf = Configuration.defaultConfiguration();
//Works fine
List<String> genders0 = JsonPath.using(conf).read(json, "$[0]['gender']");
List<String> genders0 = JsonPath.using(conf).parse(json).read("$[0]['gender']");
//PathNotFoundException thrown
List<String> genders1 = JsonPath.using(conf).read(json, "$[1]['gender']");
List<String> genders1 = JsonPath.using(conf).parse(json).read("$[1]['gender']");
```
**SUPPRESS_EXCEPTIONS**
<br/>

Loading…
Cancel
Save