import zipfile import json # Need to add option flags to specify the file path to the agent archive = zipfile.ZipFile("dqn_v2-5/ALE-Pacman-v5.zip", "r") file = archive.open("data") byte_file = file.read() json_file = json.loads(byte_file.decode("utf-8")) # Only want to remove serialized objects from dictionary val_to_remove = ":serialized:" for key in json_file.keys(): # So if each value is a type dict, then I want to iterate through it and remove the serialized key if type(json_file[key]) is dict: if val_to_remove in json_file[key].keys(): json_file[key].pop(val_to_remove) outfile = open("configtest.json", "w") json.dump(json_file, outfile, indent=2,) file.close() outfile.close()