RDFLib / sparqlwrapper

A wrapper for a remote SPARQL endpoint
https://sparqlwrapper.readthedocs.io/
Other
513 stars 121 forks source link

json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes #163

Open WolfgangFahl opened 3 years ago

WolfgangFahl commented 3 years ago

When doing a query with some 400.000 result records via Wikidata i get the error message:

File "/Users/wf/Library/Python/3.8/lib/python/site-packages/SPARQLWrapper/SmartWrapper.py", line 315, in query

    return Bindings(res)
  File "/Users/wf/Library/Python/3.8/lib/python/site-packages/SPARQLWrapper/SmartWrapper.py", line 112, in __init__
    self.fullResult = retval._convertJSON()
  File "/Users/wf/Library/Python/3.8/lib/python/site-packages/SPARQLWrapper/Wrapper.py", line 1201, in _convertJSON
    return json.loads(self.response.read().decode("utf-8"))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 4232823 column 5 (char 101638729)

The need here is to be able to debug the JSON result. For that it would be great if the Wrapper had a debug option which allows to store the JSON result to a file before it being fed to convertJSON - where in this case the JSONDecodeError makes the software choke and loose all traces of debugging (if not really using a debugger within an IDE).

But even in in IDE such big results are not easy to debug - especiaally when the call is just a parameter to json.loads().

If i finde the time i might fork sparqlwrapper and create a fitting pull request.