import ast


def get_input(arg, valid_keys):
    """Convert the input to a dict and perform basic validation"""
    json_string = arg.replace("\\n", "\n")
    try:
        input_dict = ast.literal_eval(json_string)
        if not all(k in input_dict for k in valid_keys):
            return None
    except Exception:
        return None

    return input_dict