from datetime import datetime


def _handler(obj):
    """Handle serialization for sets and datetime objects"""
    if type(obj) is set:
        return list(obj)
    elif isinstance(obj, datetime) and hasattr(obj, 'isoformat'):
        return obj.isoformat()
    else:
        raise TypeError(repr(obj) + ' is not JSON serializable')