Skip to content

Commit 02e0e5a

Browse files
author
Adam Bloomston
committed
fix for foo.[*] where foo is null
1 parent 2a37ef7 commit 02e0e5a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jsonpath_rw/jsonpath.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class Index(JSONPath):
430430
JSONPath that matches indices of the current datum, or none if not large enough.
431431
Concrete syntax is brackets.
432432
433-
WARNING: If the datum is not long enough, it will not crash but will not match anything.
433+
WARNING: If the datum is None or not long enough, it will not crash but will not match anything.
434434
NOTE: For the concrete syntax of `[*]`, the abstract syntax is a Slice() with no parameters (equiv to `[:]`
435435
"""
436436

@@ -440,7 +440,7 @@ def __init__(self, index):
440440
def find(self, datum):
441441
datum = DatumInContext.wrap(datum)
442442

443-
if len(datum.value) > self.index:
443+
if datum.value and len(datum.value) > self.index:
444444
return [DatumInContext(datum.value[self.index], path=self, context=datum)]
445445
else:
446446
return []

0 commit comments

Comments
 (0)