from datetime import datetime


def default_serializer(obj):
    """
    Function to handle JSON serialization of objects that cannot be natively serialized
    :param obj: object to seralize
    :return: JSON-compatible representation of object
    """
    if isinstance(obj, (datetime)):
        return obj.isoformat()
    raise TypeError ("Type %s not serializable" % type(obj))