8 lines
194 B
Python
8 lines
194 B
Python
|
from datetime import datetime, date
|
||
|
|
||
|
|
||
|
def json_encoder(obj):
|
||
|
if isinstance(obj, (datetime, date)):
|
||
|
return obj.isoformat()
|
||
|
raise TypeError("Type %s not serializable" % type(obj))
|