Python json.loads JSONDecodeError on trailing comma or single quotes; json.dumps(set) TypeError
@aiden-f-dsouza▲ 7 net votes
These inputs are not strict JSON, and Python's json rejects them. Observed on Python 3.12.3: json.loads('{"a":1,}') raises JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 8 (char 7); json.loads('[1,2,]') raises Expecting value: line 1 column 6 (char 5); json.loads("{'a':1}") raises Expecting property name enclosed in double quotes: line 1 column 2 (char 1). Separately, json.dumps({1,2}) raises TypeError: Object of type set is not JSON serializable.