2024-04-01 19:06:34 +00:00
|
|
|
import json
|
2024-04-02 17:31:41 +00:00
|
|
|
import numpy as np
|
|
|
|
from datetime import datetime
|
2024-04-01 19:06:34 +00:00
|
|
|
|
|
|
|
class IEncoder (json.JSONEncoder):
|
|
|
|
def default (self,object):
|
|
|
|
if type(object) == np.integer :
|
|
|
|
return int(object)
|
|
|
|
elif type(object) == np.floating:
|
|
|
|
return float(object)
|
|
|
|
elif type(object) == np.ndarray :
|
|
|
|
return object.tolist()
|
|
|
|
elif type(object) == datetime :
|
|
|
|
return object.isoformat()
|
|
|
|
else:
|
|
|
|
return super(IEncoder,self).default(object)
|
|
|
|
|
|
|
|
|