Created
April 19, 2013 06:54
-
-
Save xordoquy/5418586 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import json | |
>>> json.dumps({1: b'\xd1\x88\xd1\x82'}) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/__init__.py", line 226, in dumps | |
return _default_encoder.encode(obj) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 188, in encode | |
chunks = self.iterencode(o, _one_shot=True) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 246, in iterencode | |
return _iterencode(o, 0) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 170, in default | |
raise TypeError(repr(o) + " is not JSON serializable") | |
TypeError: b'\xd1\x88\xd1\x82' is not JSON serializable | |
>>> json.dumps({1: "шт".encode('utf8')}) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/__init__.py", line 226, in dumps | |
return _default_encoder.encode(obj) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 188, in encode | |
chunks = self.iterencode(o, _one_shot=True) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 246, in iterencode | |
return _iterencode(o, 0) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 170, in default | |
raise TypeError(repr(o) + " is not JSON serializable") | |
TypeError: b'\xd1\x88\xd1\x82' is not JSON serializable | |
>>> json.dumps({1: "шт"}) | |
'{"1": "\\u0448\\u0442"}' | |
>>> len("\\u0448\\u0442") | |
12 | |
>>> ^D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment