from __future__ import annotations import json from pathlib import Path from typing import Any def load_json(path: str | Path) -> Any: with Path(path).open("r", encoding="utf-8") as file: return json.load(file) def save_json(path: str | Path, data: Any) -> None: target = Path(path) target.parent.mkdir(parents=True, exist_ok=True) with target.open("w", encoding="utf-8") as file: json.dump(data, file, ensure_ascii=False, indent=2) file.write("\n")