mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 04:08:56 -05:00
Proper json save/load
Might fix json corruption issues
This commit is contained in:
parent
f5a628214b
commit
0c3d4a104a
@ -46,13 +46,13 @@ class DataIO():
|
|||||||
|
|
||||||
def _read_json(self, filename):
|
def _read_json(self, filename):
|
||||||
with open(filename, encoding='utf-8', mode="r") as f:
|
with open(filename, encoding='utf-8', mode="r") as f:
|
||||||
data = json.loads(f.read())
|
data = json.load(f)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _save_json(self, filename, data):
|
def _save_json(self, filename, data):
|
||||||
with open(filename, encoding='utf-8', mode="w") as f:
|
with open(filename, encoding='utf-8', mode="w") as f:
|
||||||
f.write(json.dumps(data,indent=4,sort_keys=True,
|
json.dump(data, f, indent=4,sort_keys=True,
|
||||||
separators=(',',' : ')))
|
separators=(',',' : '))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _restore_json(self, filename):
|
def _restore_json(self, filename):
|
||||||
@ -81,7 +81,7 @@ class DataIO():
|
|||||||
|
|
||||||
def get_value(filename, key):
|
def get_value(filename, key):
|
||||||
with open(filename, encoding='utf-8', mode="r") as f:
|
with open(filename, encoding='utf-8', mode="r") as f:
|
||||||
data = json.loads(f.read())
|
data = json.load(f)
|
||||||
return data[key]
|
return data[key]
|
||||||
|
|
||||||
def set_value(filename, key, value):
|
def set_value(filename, key, value):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user