0

I have read just about every json loads out there: Python json.loads fails with `ValueError: Invalid control character at: line 1 column 33 (char 33)`
Python Json lower case nan
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Single versus double quotes in json loads in Python

I have replaced single quotes with double quotes, I have changed nan to NaN, I have checked for carriage returns, I encoded it as utf-8. Still I am getting an error when trying json.loads or ast.literval_eval.

JSONDecodeError: Expecting value: line 1 column 33 (char 32)
ValueError: malformed node or string: <_ast.Name object at 0x0000016583978160>

The string starts like this

temp3[:50]
>>> '{"firstOTDriveAlreadyHappened": False, "NeedsHomeA'

Any ideas?

____SOLUTION___

Mentioned in a comment, but I had to make the following maps:

temp3 = temp3.replace('False', 'false')
temp3 = temp3.replace('True', 'true')
temp3 = temp3.replace('None', 'null')
temp3 = temp3.replace('nan', 'NaN')
temp3 = temp3.replace("'", '"')

https://docs.python.org/3/library/json.html#encoders-and-decoders

qwertylpc
  • 2,016
  • 7
  • 24
  • 34

0 Answers0