|
@@ -78,12 +78,13 @@ class labkeyDB:
|
|
|
return self.toJSON(response)
|
|
|
|
|
|
def toJSON(self,response):
|
|
|
- encoding=chardet.detect(response.data)["encoding"]
|
|
|
+ data=response.data
|
|
|
+ encoding=chardet.detect(data)["encoding"]
|
|
|
#try with a set of encodings to maximize probability of success
|
|
|
encodings=[encoding,'utf_8']
|
|
|
for x in encodings:
|
|
|
try:
|
|
|
- return json.loads(response.data.decode(x))
|
|
|
+ return json.loads(data.decode(x))
|
|
|
except UnicodeDecodeError:
|
|
|
print(f'Failed to decode with [{x}]: {data}')
|
|
|
return None
|