Spaces:
Sleeping
Sleeping
File size: 416 Bytes
0feef8c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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)
|