Expecting property name enclosed in double quotes: line 406865 column 8 (char 11883759)
I got when running a SPARQL query against a Wikidata endpoint i modified the _convertJSON function to allow
to inspect the Json String that is the culprit:
def _convertJSON(self):
"""
Convert a JSON result into a Python dict. This method can be overwritten in a subclass
for a different conversion method.
:return: converted result.
:rtype: dict
"""
jsonStr=self.response.read().decode("utf-8")
try:
return json.loads(jsonStr)
except json.decoder.JSONDecodeError as jde:
jsonFileName="/tmp/sparqlerror.json"
with open(jsonFileName,"w") as jsonFile:
jsonFile.write(jsonStr)
raise jde
the inspection of the /tmp/sparqlerror.json file revealed:
So it looks that there is a timeout and the timeout information is written directly into the json stream and not catched in any other way by the library. So it would be good to be able to inspect the string causing the json decode to choke as a standard feature.
The query that caused this behavior is shown below. It is run "per region" for our purpose and is successful in some 3000 + cases for most of the regions of the world. But for some regions with a very high number of human settlements that are known to wikidata the timeout was observed by us:
I think the library should have a built-in option to analyze the json result further. The hint
This method can be overwritten in a subclass for a different conversion method.
already gives a hint that a specialized version of the standard approach migh be possible. How would the overriding be achieved?
I am willing to create a pullrequest based on the results of the discussion of this issue.
The same issue arises if an endpoint is not properly set e.g. if you try to use https://query.wikidata.org/ as an endpoint which will return HTML code and not JSON.
since i couldn't make anything of the Exception
I got when running a SPARQL query against a Wikidata endpoint i modified the _convertJSON function to allow to inspect the Json String that is the culprit:
the inspection of the /tmp/sparqlerror.json file revealed:
So it looks that there is a timeout and the timeout information is written directly into the json stream and not catched in any other way by the library. So it would be good to be able to inspect the string causing the json decode to choke as a standard feature.
For FR-GES and IN-WB a second attempt was successful while the other two seem to systematically timeout.
try it!
I think the library should have a built-in option to analyze the json result further. The hint This method can be overwritten in a subclass for a different conversion method. already gives a hint that a specialized version of the standard approach migh be possible. How would the overriding be achieved?
I am willing to create a pullrequest based on the results of the discussion of this issue.