import json with open("/mnt/petrelfs/zhuchenglin/clipscore/coco_gen_200k copy.json", "r") as f: data = json.load(f) # Convert the data to a list of dictionaries data = [{"id": key, "clipscore": value["CLIPScore"]} for key, value in data.items()] # Save the modified data with open("/mnt/petrelfs/zhuchenglin/clipscore/coco_gen_200k.json", "w") as f: json.dump(data, f)