Fixed escape_forward_slashes error

This commit is contained in:
Profitroll 2023-08-06 01:25:08 +02:00
parent dc107ebdb3
commit 11d49fd476
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
2 changed files with 7 additions and 1 deletions

View File

@ -35,6 +35,8 @@ async def json_write(data: Any, path: Union[str, Path]) -> None:
async with aiofiles.open(str(path), mode="w", encoding="utf-8") as f: async with aiofiles.open(str(path), mode="w", encoding="utf-8") as f:
await f.write( await f.write(
dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4) dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)
if hasattr(dumps, "escape_forward_slashes")
else dumps(data, ensure_ascii=False, indent=4)
) )

View File

@ -29,7 +29,11 @@ def json_write(data: Any, path: Union[str, Path]) -> None:
* path (`Union[str, Path]`): Path-like object or path as a string of a destination * path (`Union[str, Path]`): Path-like object or path as a string of a destination
""" """
with open(str(path), mode="w", encoding="utf-8") as f: with open(str(path), mode="w", encoding="utf-8") as f:
f.write(dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)) f.write(
dumps(data, ensure_ascii=False, escape_forward_slashes=False, indent=4)
if hasattr(dumps, "escape_forward_slashes")
else dumps(data, ensure_ascii=False, indent=4)
)
def nested_set(target: dict, value: Any, *path: str, create_missing=True) -> dict: def nested_set(target: dict, value: Any, *path: str, create_missing=True) -> dict: