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