Spaces:
Build error
Build error
File size: 536 Bytes
a1da63c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import json
from json import JSONDecodeError
from typing import Optional
from facefusion.filesystem import is_file
from facefusion.typing import Content
def read_json(json_path : str) -> Optional[Content]:
if is_file(json_path):
try:
with open(json_path, 'r') as json_file:
return json.load(json_file)
except JSONDecodeError:
pass
return None
def write_json(json_path : str, content : Content) -> bool:
with open(json_path, 'w') as json_file:
json.dump(content, json_file, indent = 4)
return is_file(json_path)
|