garmentiq.utils.export_dict_to_json
1import json 2 3 4def export_dict_to_json(data: dict, filename: str): 5 """ 6 Export a dictionary to a JSON file. 7 8 Args: 9 data (dict): The dictionary to export. 10 filename (str): The path to the JSON file (e.g., "output.json"). 11 """ 12 try: 13 with open(filename, "w", encoding="utf-8") as f: 14 json.dump(data, f, indent=2, ensure_ascii=False) 15 except Exception as e: 16 print(f"Failed to export dictionary: {e}")
def
export_dict_to_json(data: dict, filename: str):
5def export_dict_to_json(data: dict, filename: str): 6 """ 7 Export a dictionary to a JSON file. 8 9 Args: 10 data (dict): The dictionary to export. 11 filename (str): The path to the JSON file (e.g., "output.json"). 12 """ 13 try: 14 with open(filename, "w", encoding="utf-8") as f: 15 json.dump(data, f, indent=2, ensure_ascii=False) 16 except Exception as e: 17 print(f"Failed to export dictionary: {e}")
Export a dictionary to a JSON file.
Arguments:
- data (dict): The dictionary to export.
- filename (str): The path to the JSON file (e.g., "output.json").