def cast_to_dict(object) -> dict:
    """Try to cast an object as a dict."""
    if isinstance(object, dict):
        return {key: cast_to_dict(val) for key, val in object.items()}
    elif isinstance(object, str):
        extract_json_attempt = parse_json(object)
        if extract_json_attempt:
            return extract_json_attempt
        return object
    else:
        return object
Try to cast an object as a dict.
vlmeval/dataset/utils/megabench/scoring/common/conversions.py