Save data to JSON file Args: data: Data to save filepath: Path to save the JSON file
(data: Union[Dict, List], filepath: str)
| 31 | |
| 32 | |
| 33 | def save_json(data: Union[Dict, List], filepath: str) -> None: |
| 34 | """ |
| 35 | Save data to JSON file |
| 36 | |
| 37 | Args: |
| 38 | data: Data to save |
| 39 | filepath: Path to save the JSON file |
| 40 | """ |
| 41 | os.makedirs(os.path.dirname(filepath), exist_ok=True) |
| 42 | with open(filepath, 'w', encoding='utf-8') as f: |
| 43 | json.dump(data, f, indent=2, ensure_ascii=False) |
| 44 | |
| 45 | |
| 46 | def load_json(filepath: str) -> Union[Dict, List]: |
no outgoing calls
no test coverage detected