diff --git a/jsonpath_ng/jsonpath.py b/jsonpath_ng/jsonpath.py index 550b52c..290fc98 100644 --- a/jsonpath_ng/jsonpath.py +++ b/jsonpath_ng/jsonpath.py @@ -792,11 +792,11 @@ def find(self, datum): datum = DatumInContext.wrap(datum) # Used for catching null value instead of empty list in path - if not datum.value: + if datum.value is None: return [] # Here's the hack. If it is a dictionary or some kind of constant, # put it in a single-element list - if (isinstance(datum.value, dict) or isinstance(datum.value, int) or isinstance(datum.value, str)): + if (isinstance(datum.value, dict) or isinstance(datum.value, (int, float, str, bool))): return self.find(DatumInContext([datum.value], path=datum.path, context=datum.context)) # Some iterators do not support slicing but we can still diff --git a/tests/test_jsonpath.py b/tests/test_jsonpath.py index abd105e..7ccf900 100644 --- a/tests/test_jsonpath.py +++ b/tests/test_jsonpath.py @@ -241,6 +241,11 @@ def test_update(parse: Callable[[str], JSONPath], expression: str, data, update_ # -------------------- # ("[*]", 1, [1], ["[0]"]), + ("[*]", 1.2, [1.2], ["[0]"]), + ("[*]", True, [True], ["[0]"]), + ("[*]", False, [False], ["[0]"]), + ("[*]", "test", ["test"], ["[0]"]), + ("[*]", None, [], []), ("[0:]", 1, [1], ["[0]"]), ("[*]", {"foo": 1}, [{"foo": 1}], ["[0]"]), ("[*].foo", {"foo": 1}, [1], ["[0].foo"]),