def character_talents(talent_data):
    """Accepts a JSON object containing a players talents
    and returns the players current active specalization."""
    talents = talent_data["talents"]

    # Starts empty just incase the player hasn't got a spec selected.
    active_spec = ""

    for talent in talents:
        # The API returns the selected key only if it's selected, therefore this check
        # makes sure we're not looking for something that doesn't exist.
        if "selected" in talent.keys():
            if talent["selected"] == True:
                active_spec = talent["spec"]["name"]

    talent_data = {"active_spec": active_spec}

    return talent_data