Fixes caused by errors during parsing non-perfect JSON files with different schema.
from jsonpath_ng.ext import parse
jsonpath_expr = parse("$.store.book[*].category")
json_file = """
{
"store": {
"book": null,
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}
"""
result = [
match.value for match in jsonpath_expr.find(
json.loads(json_file)
)
]
For example, after execution code block above got a TypeError:
File "/usr/local/lib/python3.7/site-packages/jsonpath_ng/jsonpath.py", line 255, in find
for subdata in self.left.find(datum)
File "/usr/local/lib/python3.7/site-packages/jsonpath_ng/jsonpath.py", line 255, in find
for subdata in self.left.find(datum)
File "/usr/local/lib/python3.7/site-packages/jsonpath_ng/jsonpath.py", line 257, in <listcomp>
for submatch in self.right.find(subdata)]
File "/usr/local/lib/python3.7/site-packages/jsonpath_ng/jsonpath.py", line 628, 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()
Coverage remained the same at ?% when pulling 3e36466972449bedf9ac572dfbb8115a3760d1d7 on borysvorona:master into 003a0b78f8a1857aa7027a837def54564a2b578a on h2non:master.
Fixes caused by errors during parsing non-perfect JSON files with different schema.
For example, after execution code block above got a TypeError: