'Implement this method in a subclass such that it returns a
serializable object for ``o``, or calls the base implementation (to
raise a :exc:`TypeError`).
For example, to support arbitrary iterators, you could implement
default like this::
def default(self, o):
try:
iterable = iter(o)
except TypeError:
pass
else:
return list(iterable)
return JSONEncoder.default(self, o)'

def default(self, o):

    if isinstance(o, datetime):
        return http_date(o.utctimetuple())
    if isinstance(o, date):
        return http_date(o.timetuple())
    if isinstance(o, uuid.UUID):
        return str(o)
    if hasattr(o, '__html__'):
        return text_type(o.__html__())
    return _json.JSONEncoder.default(self, o)
