This commit follow and ammend
3d42e56d0da85a1e1 .
The JSON serializer will handle simple numpy data type as number and boolean and will simply convert them to native python type. For such type there is no need to preserve the numpy dtype like it is the case with numpy arrays.
if isinstance(obj, numpy.ndarray):
return {'numpyArray': obj.tolist(),
'dtype': obj.dtype.__str__()}
- raise TypeError(repr(obj) + " is not JSON serializable")
+ elif isinstance(obj, numpy.generic):
+ return numpy.asscalar(obj)
+ else:
+ print obj
+ print type(obj)
+ raise TypeError(repr(obj) + " is not JSON serializable")
json_str = json.dumps([res.as_dict() for res in self.values()],
default=NumpyArrayEncoder)