[+] Create toJson util method

This commit is contained in:
Hykilpikonna
2020-11-22 13:15:25 -05:00
parent aa5e0711a7
commit e029ee7b7e
2 changed files with 7 additions and 1 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
import json
from src.constants import dbPath
from src.utils import toJson
class Database:
@@ -10,5 +11,5 @@ class Database:
def save(self):
f = open(dbPath, 'w')
f.write(json.dumps(self))
f.write(toJson(self))
f.close()
+5
View File
@@ -0,0 +1,5 @@
import json
def toJson(obj):
return json.dumps(obj, default=lambda o: o.__dict__, sort_keys=True, indent=4)