summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Bloomston <mail@adambloomston>2015-10-01 21:11:40 -0400
committerAdam Bloomston <mail@adambloomston>2015-10-01 21:11:40 -0400
commit02e0e5ac40146c3d0d359a955a926838f070371d (patch)
tree039458c5cc1624fefc0ec32703b8a3e4bb15c686
parent2a37ef714c66a50faa09193fd0af1a6a55639c5c (diff)
downloadjsonpath-rw-02e0e5ac40146c3d0d359a955a926838f070371d.tar.gz
fix for foo.[*] where foo is null
-rw-r--r--jsonpath_rw/jsonpath.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/jsonpath_rw/jsonpath.py b/jsonpath_rw/jsonpath.py
index 3c491d0..f2cd82e 100644
--- a/jsonpath_rw/jsonpath.py
+++ b/jsonpath_rw/jsonpath.py
@@ -430,7 +430,7 @@ class Index(JSONPath):
JSONPath that matches indices of the current datum, or none if not large enough.
Concrete syntax is brackets.
- WARNING: If the datum is not long enough, it will not crash but will not match anything.
+ WARNING: If the datum is None or not long enough, it will not crash but will not match anything.
NOTE: For the concrete syntax of `[*]`, the abstract syntax is a Slice() with no parameters (equiv to `[:]`
"""
@@ -440,7 +440,7 @@ class Index(JSONPath):
def find(self, datum):
datum = DatumInContext.wrap(datum)
- if len(datum.value) > self.index:
+ if datum.value and len(datum.value) > self.index:
return [DatumInContext(datum.value[self.index], path=self, context=datum)]
else:
return []