[issue39258] json serialiser errors with numpy int64

2020-01-08 Thread Tony Hirst


Change by Tony Hirst :


--
components: Library (Lib)
nosy: Tony Hirst
priority: normal
severity: normal
status: open
title: json serialiser errors with numpy int64
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue39258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39258] json serialiser errors with numpy int64

2020-01-08 Thread Tony Hirst


New submission from Tony Hirst :


import json
import numpy as np

json.dumps( {'int64': np.int64(1)})

TypeError: Object of type int64 is not JSON serializable 
---
TypeError Traceback (most recent call last)
 in 
> 1 json.dumps( {'int64': np.int64(1)})

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py
 in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, 
separators, default, sort_keys, **kw)
229 cls is None and indent is None and separators is None and
230 default is None and not sort_keys and not kw):
--> 231 return _default_encoder.encode(obj)
232 if cls is None:
233 cls = JSONEncoder

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py
 in encode(self, o)
197 # exceptions aren't as detailed.  The list call should be 
roughly
198 # equivalent to the PySequence_Fast that ''.join() would do.
--> 199 chunks = self.iterencode(o, _one_shot=True)
200 if not isinstance(chunks, (list, tuple)):
201 chunks = list(chunks)

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py
 in iterencode(self, o, _one_shot)
255 self.key_separator, self.item_separator, self.sort_keys,
256 self.skipkeys, _one_shot)
--> 257 return _iterencode(o, 0)
258 
259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py
 in default(self, o)
177 
178 """
--> 179 raise TypeError(f'Object of type {o.__class__.__name__} '
180 f'is not JSON serializable')
181 

TypeError: Object of type int64 is not JSON serializable



--

___
Python tracker 
<https://bugs.python.org/issue39258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39258] json serialiser errors with numpy int64

2020-01-08 Thread Tony Hirst


Tony Hirst  added the comment:

Apols - this is probably strictly a numpy issue.

See: https://github.com/numpy/numpy/issues/12481

--

___
Python tracker 
<https://bugs.python.org/issue39258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39258] json serialiser errors with numpy int64

2020-01-08 Thread Tony Hirst


Tony Hirst  added the comment:

Previously posted issue: https://bugs.python.org/issue22107

--

___
Python tracker 
<https://bugs.python.org/issue39258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39258] json serialiser errors with numpy int64

2020-01-08 Thread Tony Hirst


Tony Hirst  added the comment:

Argh: previous was incorrect associated issue: correct issue: 
https://bugs.python.org/issue24313

--

___
Python tracker 
<https://bugs.python.org/issue39258>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com