We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
jsonpath.Slice
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When specifying a json path that contains a [*], if the value is None then a TypeError is raises.
[*]
None
TypeError
No exception is raised, and an empty result set is returned.
>>> import jsonpath_rw >>> d = {"key": None} >>> p = jsonpath_rw.parse('$.key.[*].value') >>> p.find(d) Traceback (most recent call last): File "<input>", line 1, in <module> p.find(d) File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py", line 226, in find for subdata in self.left.find(datum) File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py", line 226, in find for subdata in self.left.find(datum) File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py", line 228, in <listcomp> for submatch in self.right.find(subdata)] File "lib/python3.6/site-packages/jsonpath_rw/jsonpath.py", line 494, in find return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in xrange(0, len(datum.value) )] TypeError: object of type 'NoneType' has no len()
tested against python3.6 and jsonpath_rw==1.4.0
python3.6
jsonpath_rw==1.4.0
edit: this seems to be fixed by #77, but I can't find the corresponding issue
The text was updated successfully, but these errors were encountered:
I'm experiencing the same issue. Pip installed from github/master. Python 3.9.1.
Possibly second problem (that might be related/close)?:
>>> jsonpath_rw.parse("list[*]").find({"list": None}) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/root/.local/lib/python3.9/site-packages/jsonpath_rw/jsonpath.py", line 229, in find return [submatch File "/root/.local/lib/python3.9/site-packages/jsonpath_rw/jsonpath.py", line 232, in <listcomp> for submatch in self.right.find(subdata)] File "/root/.local/lib/python3.9/site-packages/jsonpath_rw/jsonpath.py", line 546, in find return [DatumInContext(datum.value[i], path=Index(i), context=datum) for i in xrange(0, len(datum.value))] TypeError: object of type 'NoneType' has no len() >>> jsonpath_rw.parse("list[*]").find({"list": 1}) [DatumInContext(value=1, path=<jsonpath_rw.jsonpath.Index object at 0x7f1cb1d6a3d0>, context=DatumInContext(value=[1], path=Fields('list'), context=DatumInContext(value={'list': 1}, path=This(), context=None)))] >>> jsonpath_rw.parse("list[*]").find({"list": "foo"}) [DatumInContext(value='foo', path=<jsonpath_rw.jsonpath.Index object at 0x7f17f674d1f0>, context=DatumInContext(value=['foo'], path=Fields('list'), context=DatumInContext(value={'list': 'foo'}, path=This(), context=None)))]
The array-syntax shouldn't match an int or string (nor other types)?
This issue (and the referenced PR) is fairly old though. Is this library alive and well?
Sorry, something went wrong.
Discussion regarding the health of this library #73
No branches or pull requests
When specifying a json path that contains a
[*]
, if the value isNone
then aTypeError
is raises.Expected behavior
No exception is raised, and an empty result set is returned.
Minimal reproduction of the issue
Version
tested against
python3.6
andjsonpath_rw==1.4.0
edit: this seems to be fixed by #77, but I can't find the corresponding issue
The text was updated successfully, but these errors were encountered: