mirror of
https://github.com/aclist/dztui.git
synced 2026-08-27 18:27:07 +02:00
21 lines
417 B
Python
21 lines
417 B
Python
import json
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
def read_json(path: Path) -> Any:
|
|
try:
|
|
with open(path, "r") as infile:
|
|
data = json.load(infile)
|
|
return data
|
|
except Exception as e:
|
|
raise e
|
|
|
|
|
|
def write_json(data: dict, path: Path) -> None:
|
|
try:
|
|
j = json.dumps(data, indent=2)
|
|
path.write_text(j)
|
|
except Exception as e:
|
|
raise e
|