Created
February 13, 2013 08:11
-
-
Save andycasey/4943031 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
mrmagoo:smh andycasey$ python -c 'import json;import numpy as np;a=np.arange(5);b=a.tolist();c=list(a);print b,c,b==c;print json.dumps(b);print json.dumps(c)' | |
[0, 1, 2, 3, 4] [0, 1, 2, 3, 4] True | |
[0, 1, 2, 3, 4] | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/json/__init__.py", line 231, in dumps | |
return _default_encoder.encode(obj) | |
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/json/encoder.py", line 201, in encode | |
chunks = self.iterencode(o, _one_shot=True) | |
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/json/encoder.py", line 264, in iterencode | |
return _iterencode(o, 0) | |
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/json/encoder.py", line 178, in default | |
raise TypeError(repr(o) + " is not JSON serializable") | |
TypeError: 0 is not JSON serializable |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, it looks like this behaviour has been fixed in a recent version of json/numpy.