SmartDayAI / src /utils /storage.py
rahulmolasi's picture
Rename utils/storage.py to src/utils/storage.py
9906c3c verified
Raw History Blame Contribute Delete
416 Bytes
import json, os
def load_json(file_path):
if os.path.exists(file_path):
with open(file_path, "r") as f:
try:
return json.load(f)
except json.JSONDecodeError:
return []
return []
def save_json(file_path, data):
os.makedirs(os.path.dirname(file_path), exist_ok=True)
with open(file_path, "w") as f:
json.dump(data, f, indent=4)