Ethan Furman added the comment: For the curious, here are all the tracebacks:
--> json.dumps(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.3/json/__init__.py", line 236, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.3/json/encoder.py", line 191, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.3/json/encoder.py", line 249, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.3/json/encoder.py", line 173, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: array([ True, True, True, True, False, False], dtype=bool) is not JSON serializable --> json.dumps(a[0]) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.3/json/__init__.py", line 236, in dumps return _default_encoder.encode(obj) File "/usr/lib/python3.3/json/encoder.py", line 191, in encode chunks = self.iterencode(o, _one_shot=True) File "/usr/lib/python3.3/json/encoder.py", line 249, in iterencode return _iterencode(o, 0) File "/usr/lib/python3.3/json/encoder.py", line 173, in default raise TypeError(repr(o) + " is not JSON serializable") TypeError: True is not JSON serializable While the repr says 'True', the type is <class 'numpy.bool_'>. and the success: --> json.dumps(a.tolist()) #this works! '[true, true, true, true, false, false]' Summary ======= No bug here, defined behavior. Raising the issue with NumPy won't help as this is not a bug... although perhaps they have a json handler already written somewhere? At any rate, yes, said handler would have to be specified as the 'default' parameter. ---------- resolution: -> invalid status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18303> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com