Datasets:
File size: 516 Bytes
b8ea052 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | """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")
|