mirror of
https://github.com/facefusion/facefusion.git
synced 2026-04-29 13:05:59 +02:00
23 lines
530 B
Python
23 lines
530 B
Python
import json
|
|
from json import JSONDecodeError
|
|
from typing import Optional
|
|
|
|
from facefusion.filesystem import is_file
|
|
from facefusion.types import Content
|
|
|
|
|
|
def read_json(json_path : str) -> Optional[Content]:
|
|
if is_file(json_path):
|
|
try:
|
|
with open(json_path) 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)
|