But if such a property name starts with reserved JS keywords (like true or null) it fails:
>>> chompjs.parse_js_object('{trueaaaa: 10}')
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/mariusz/Documents/Praca/venv/lib/python3.9/site-packages/chompjs/chompjs.py", line 25, in parse_js_object
return json.loads(parsed_data, **json_params)
File "/usr/lib/python3.9/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.9/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
The lib can handle unquoted properties:
But if such a property name starts with reserved JS keywords (like
true
ornull
) it fails: