Files
Attributes related to parsing and editing files.
EditableJSON
2.0.0
class nightylib.util.EditableJSON(path: str, data: Optional[dict[str, Any]] = None)
This class allows you to dynamically edit JSON files during runtime.
Example: create a new JSON file and edit it
from nightylib.util import EditableJSON
from pathlib import Path
downloads = Path.home() / "Downloads"
file = downloads / "example.json"
with open(file, "w", encoding="utf-8") as f:
f.write("{}")
editable = EditableJSON(str(file))
editable.hello = "Hi!"
print(editable.hello)
del editable.hello