19 lines
367 B
Python
19 lines
367 B
Python
|
|
import json
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
|
||
|
|
def save_json(vocabulary: dict, path: Path):
|
||
|
|
|
||
|
|
json_string = json.dumps(vocabulary)
|
||
|
|
FILE = open(path, "w")
|
||
|
|
FILE.write(json_string)
|
||
|
|
FILE.close()
|
||
|
|
|
||
|
|
|
||
|
|
def load_json(path: Path) -> dict[tuple[int, int], int]:
|
||
|
|
FILE = open(path, "r")
|
||
|
|
json_string = FILE.read()
|
||
|
|
FILE.close()
|
||
|
|
|
||
|
|
return json.loads(json_string)
|