import json


def check_role_in_retrieved_nym(retrieved_nym, role):
    """
    Check if the role in the GET NYM response is what we want.

    :param retrieved_nym:
    :param role: the role we want to check.
    :return: True if the role is what we want.
             False if the role is not what we want.
    """
    if retrieved_nym is None:
        return False
    nym_dict = json.loads(retrieved_nym)
    if "data" in nym_dict["result"]:
        temp_dict = json.loads(nym_dict["result"]["data"])
        if "role" in temp_dict:
            if not temp_dict["role"] == role:
                return False
            else:
                return True
    return False