Looks like you need to modify the json.py you referenced and add a block to handle the type.
Look at how datetime.datetime
is handled at line 61:
elif isinstance(obj, datetime.datetime):
output = {}
fields = ['day', 'hour', 'microsecond', 'minute', 'month', 'second',
'year']
methods = ['ctime', 'isocalendar', 'isoformat', 'isoweekday',
'timetuple']
for field in fields:
output[field] = getattr(obj, field)
for method in methods:
output[method] = getattr(obj, method)()
output['epoch'] = time.mktime(obj.timetuple())
return output
You need to add something to handle datetime.date
:
elif isinstance(obj, datetime.date):
#your code here...
Or just use datetime.datetime
instead of datetime.date
.