def decode_nested_json()

in src/nova_act/impl/common.py [0:0]


def decode_nested_json(obj: dict | list | str):
    """Decode a mixed JSON dict/list/string."""
    if isinstance(obj, dict):
        return {key: decode_nested_json(value) for key, value in obj.items()}
    elif isinstance(obj, list):
        return [decode_nested_json(value) for value in obj]
    elif isinstance(obj, str):
        try:
            return decode_nested_json(json.loads(obj))
        except json.JSONDecodeError:
            return obj
    else:
        return obj