import uuid


def _parse_legacy_uuid(doc):
    """Decode a JSON legacy $uuid to Python UUID."""
    if len(doc) != 1:
        raise TypeError('Bad $uuid, extra field(s): %s' % (doc,))
    return uuid.UUID(doc["$uuid"])