"""File IO helpers for PVR eval artifacts.""" from __future__ import annotations import json from pathlib import Path from typing import Any def load_json(path: str | Path) -> dict[str, Any]: return json.loads(Path(path).read_text(encoding="utf-8")) def dump_json(payload: dict[str, Any], path: str | Path) -> None: output_path = Path(path) output_path.parent.mkdir(parents=True, exist_ok=True) output_path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")