RODY/app/utils/JSONEncodeTools.py

21 lines
434 B
Python
Raw Normal View History

2022-11-04 17:37:08 +08:00
"""
@Time 2022/10/17 10:12
@Auth
@File JSONEncodeTools.py
@IDE PyCharm
@MottoABC(Always Be Coding)
@Desc
"""
import datetime
import json
class MyEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, bytes):
return str(obj, encoding='utf-8')
if isinstance(obj, datetime.datetime):
return str(obj)
return json.JSONEncoder.default(self, obj)