| 123456789101112 |
- import datetime
- import json
- class JsonEncoder(json.JSONEncoder):
- def default(self, obj):
- if isinstance(obj, datetime.datetime):
- return obj.strftime("%Y-%m-%d %H:%M:%S")
- elif isinstance(obj, bytes):
- return str(obj, 'utf-8')
- else:
- return json.JSONEncoder.default(self, obj)
|