Rajan Sharma commited on
Commit
820b3f9
·
verified ·
1 Parent(s): 5cf4edb

Create pipeline/io_utils.py

Browse files
Files changed (1) hide show
  1. pipeline/io_utils.py +12 -0
pipeline/io_utils.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ from pathlib import Path
3
+ from typing import Any, Dict
4
+
5
+ def load_json(p: Path) -> Dict[str, Any]:
6
+ with open(p, "r", encoding="utf-8") as f:
7
+ return json.load(f)
8
+
9
+ def save_json(p: Path, data: Dict[str, Any]):
10
+ p.parent.mkdir(parents=True, exist_ok=True)
11
+ with open(p, "w", encoding="utf-8") as f:
12
+ json.dump(data, f, ensure_ascii=False, indent=2)