parent
4cb8412fd8
commit
6476488221
4 changed files with 90 additions and 2 deletions
|
@ -62,7 +62,12 @@ class JSONPathDict(object):
|
|||
def get(self, path, not_found_handler=None):
|
||||
""" Returns the value found at the given path. Path is a json-path expression. """
|
||||
jsonpath_expr = parse(path)
|
||||
matches = jsonpath_expr.find(self._object)
|
||||
|
||||
try:
|
||||
matches = jsonpath_expr.find(self._object)
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
if not matches:
|
||||
return not_found_handler() if not_found_handler else None
|
||||
|
||||
|
|
Reference in a new issue