Writing a GenericEncoder to prevent JSON conversion errors
class GenericEncoder ( json.JSONEncoder ): import numpy def default ( self , obj ) : if isinstance (obj, numpy.generic): return numpy.asscalar(obj) elif isinstance (obj, datetime.datetime): return obj.strftime( '%Y-%m-%d %H:%M:%S' ) else : return json.JSONEncoder.default( self , obj)