def default(self, o):
# to support arbitrary iterators
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
# support datetime
if isinstance(o, datetime):
# return o.isoformat() if o else ''
return datetime.strftime(o, '%Y-%m-%d %H:%M:%S') if o else ''
elif hasattr(o, '__dict__'):
return o.__dict__
return str(o)
# return JSONEncoder.default(self, o)
评论列表
文章目录