再修复json库问题

This commit is contained in:
MrZ626
2020-11-28 23:20:23 +08:00
parent 41a9f6f16d
commit 2c247a599d
2 changed files with 8 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ function FILE.load(name)
return s() return s()
else else
LOG.print(name.." "..text.loadError,COLOR.red) LOG.print(name.." "..text.loadError,COLOR.red)
return{}
end end
else else
local res=json.decode(s) local res=json.decode(s)
@@ -20,6 +21,7 @@ function FILE.load(name)
return res return res
else else
LOG.print(name.." "..text.loadError,COLOR.red) LOG.print(name.." "..text.loadError,COLOR.red)
return{}
end end
end end
end end
@@ -27,11 +29,10 @@ end
function FILE.save(data,name,mode,luacode) function FILE.save(data,name,mode,luacode)
if not mode then mode="m"end if not mode then mode="m"end
name=name..".dat" name=name..".dat"
local _,mes
if not luacode then if not luacode then
res=json.encode(res) data=json.encode(data)
if res then if not data then
LOG.print(name.." "..text.saveError..(mes or"json error"),"error") LOG.print(name.." "..text.saveError.."json error","error")
end end
else else
data=dumpTable(data) data=dumpTable(data)
@@ -39,7 +40,7 @@ function FILE.save(data,name,mode,luacode)
local F=fs.newFile(name) local F=fs.newFile(name)
F:open("w") F:open("w")
_,mes=F:write(data) local _,mes=F:write(data)
F:flush()F:close() F:flush()F:close()
if _ then if _ then
if mode:find("m")then if mode:find("m")then

View File

@@ -307,7 +307,7 @@ do--json
if a then if a then
return b return b
else else
LOG.print(text.jsonError,"warn") LOG.print(text.jsonError..": "..(b or"uknErr"),"warn")
return return
end end
end end
@@ -540,7 +540,7 @@ do--json
if a then if a then
return b return b
else else
LOG.print(text.jsonError,"warn") LOG.print(text.jsonError..": "..(b or"uknErr"),"warn")
return return
end end
end end