import base64
import six


def deserialize(obj):
    """Deserialize the given object
    :param obj: string representation of the encoded object
    :return: decoded object (its type is unicode string)
    """
    result = base64.urlsafe_b64decode(obj)
    # this workaround is needed because in case of python 3 the
    # urlsafe_b64decode method returns string of 'bytes' class
    if six.PY3:
        result = result.decode()
    return result