Question:
I have a service that takes in a JSON
string as input. The JSON
schema is different every time where some fields are
I realized what I did wrong. The DEFAULT_PATH_LEAF_TO_NULL
option only takes care of leaf nodes. For example:
Sample Json
{
"foo":{
"bar":"value"
}
}
If $.foo.tmp
is queried, JsonPath will return null
as tmp is suppose to be a leaf node.
If $.tmp.tmp2
is queried, JsonPath will throw a
com.jayway.jsonpath.PathNotFoundException as tmp isn't a leaf and is not present.
In order to bypass this, one should use Option.SUPPRESS_EXCEPTIONS
.