Skip to content

Commit b21f589

Browse files
chdemkomichaelmior
authored andcommitted
Fix False and None values
1 parent 40cc282 commit b21f589

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

jsonpath_ng/jsonpath.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def find(self, datum):
792792
datum = DatumInContext.wrap(datum)
793793

794794
# Used for catching null value instead of empty list in path
795-
if not datum.value:
795+
if datum.value is None:
796796
return []
797797
# Here's the hack. If it is a dictionary or some kind of constant,
798798
# put it in a single-element list

tests/test_jsonpath.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ def test_update(parse: Callable[[str], JSONPath], expression: str, data, update_
230230
("[*]", 1, [1], ["[0]"]),
231231
("[*]", 1.2, [1.2], ["[0]"]),
232232
("[*]", True, [True], ["[0]"]),
233+
("[*]", False, [False], ["[0]"]),
233234
("[*]", "test", ["test"], ["[0]"]),
235+
("[*]", None, [], []),
234236
("[*]", [1, 2, 3], [1, 2, 3], ["[0]", "[1]", "[2]"]),
235237
("[*]", range(1, 4), [1, 2, 3], ["[0]", "[1]", "[2]"]),
236238
("[1:]", [1, 2, 3, 4], [2, 3, 4], ["[1]", "[2]", "[3]"]),

0 commit comments

Comments
 (0)