Python: json:json.decoder.JSONDecodeError: Invalid control character at: line 2 column 18 (char 19)

1. JSON. Loads (JSON_ Json.decoder.jsondecodeerror: invalid control character at: Line 2 column 18 (char 19)

reason: JSON uses rigorous format by default, which is easy to report when data is transferred across languages

solution: add the parameter strict

json.loads(json_data, strict=False)

2. JSON. Dumps (data) to convert Chinese characters into Unicode

reason: JSON performs character conversion by default

solution: add ensure_ ASCII parameter

json.dumps(data, ensure_ascii=False)

3. JSON. Loads (JSON_ Error: JSON. Decoder. Jsondecodeerror: invalid – escape: Line 1 column 89 (char 88)

Error reason: syntax error

Solutions

Check JSON_ Data data, whether it contains illegal characters, such as backslash ‘\’, change ‘\’ to ‘\ \’

Similar Posts: