Problem details: json.decoder.jsondecodeerror: invalid control character at: Line 1 column 5515 (char 5514)
Reason: STR contains \t \n and other contents. Note that it is not the characters “\t” and “\n”. Therefore, an error is reported when checking the syntax of JSON.
If strict is false (the default is true), control characters are allowed in the string.
Solution 1: add the strict = false parameter
json.loads(f_str, strict=False)
Solution 2: replace \ t \ n with
f_str=f_str.replace('\n', ' ') f_str=f_str.replace('\t', ' ')
Done!
Similar Posts:
- Python: json:json.decoder.JSONDecodeError: Invalid control character at: line 2 column 18 (char 19)
- Python JSON error json.decoder.jsondecodeerror Chinese
- Python: How to Solve raise JSONDecodeError(“Expecting value”, s, err.value) from None json.decoder…
- [Solved] json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
- TypeError: the JSON object must be str, not ‘bytes’
- [Solved] json.decoder.JSONDecodeError: Expecting ‘,‘ delimiter: line xx column xx (char xxx)
- [Solved] Python Error: UnicodeDecodeError: ‘gb2312’ codec can’t decode byte 0xa4 in position… : illegal multibyte sequence
- [Solved] TypeError: string indices must be integers, not str
- Transcoding of system.web.httputility.urlencode in C #