def _json_fallback_handler(obj):
    """
    Serialize custom datatypes and pass the rest to __structlog__ & repr().
    """
    from structlog.threadlocal import _ThreadLocalDictWrapper
    if isinstance(obj, _ThreadLocalDictWrapper):
        return obj._dict
    else:
        try:
            return obj.__structlog__()
        except AttributeError:
            return repr(obj)
