You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Python 3.8, I tried to serialize a Python dict whose value can be a set. ujson failed to dumps() it into a JSON string. It is expected. But the error message is quite confusing
Python 3.8.2 (default, Feb 26 2020, 02:56:10)
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ujson import dumps
>>> dumps(set())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: �0d is not JSON serializable
What did you expect to happen?
ujson should have better error message that helps debugging. Here is the error message in built-in json module
>>> from json import dumps
>>> dumps(set())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python3.8/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python3.8/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python3.8/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type set is not JSON serializable
json module has much better error message
What versions are you using?
OS: Ubuntu 18.04
Python: 3.8.2
UltraJSON: 2.0.1
fromujsonimportdumpsdumps(set())
The text was updated successfully, but these errors were encountered:
Thanks, this was fixed in #382 and released in UltraJSON 2.0.2:
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ujson import dumps
>>> import ujson
>>> ujson.__version__
'2.0.3'
>>> ujson.dumps(set())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: set() is not JSON serializable
What did you do?
In Python 3.8, I tried to serialize a Python dict whose value can be a set.
ujson
failed todumps()
it into a JSON string. It is expected. But the error message is quite confusingWhat did you expect to happen?
ujson
should have better error message that helps debugging. Here is the error message in built-injson
modulejson
module has much better error messageWhat versions are you using?
The text was updated successfully, but these errors were encountered: