From 2c247a599d16bb29e22bad6eefc2feebd4c3d445 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 28 Nov 2020 23:20:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=8D=E4=BF=AE=E5=A4=8Djson=E5=BA=93?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/file.lua | 11 ++++++----- Zframework/toolfunc.lua | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Zframework/file.lua b/Zframework/file.lua index c574c30e..2327d075 100644 --- a/Zframework/file.lua +++ b/Zframework/file.lua @@ -13,6 +13,7 @@ function FILE.load(name) return s() else LOG.print(name.." "..text.loadError,COLOR.red) + return{} end else local res=json.decode(s) @@ -20,6 +21,7 @@ function FILE.load(name) return res else LOG.print(name.." "..text.loadError,COLOR.red) + return{} end end end @@ -27,11 +29,10 @@ end function FILE.save(data,name,mode,luacode) if not mode then mode="m"end name=name..".dat" - local _,mes if not luacode then - res=json.encode(res) - if res then - LOG.print(name.." "..text.saveError..(mes or"json error"),"error") + data=json.encode(data) + if not data then + LOG.print(name.." "..text.saveError.."json error","error") end else data=dumpTable(data) @@ -39,7 +40,7 @@ function FILE.save(data,name,mode,luacode) local F=fs.newFile(name) F:open("w") - _,mes=F:write(data) + local _,mes=F:write(data) F:flush()F:close() if _ then if mode:find("m")then diff --git a/Zframework/toolfunc.lua b/Zframework/toolfunc.lua index 677d36e3..f47b94be 100644 --- a/Zframework/toolfunc.lua +++ b/Zframework/toolfunc.lua @@ -307,7 +307,7 @@ do--json if a then return b else - LOG.print(text.jsonError,"warn") + LOG.print(text.jsonError..": "..(b or"uknErr"),"warn") return end end @@ -540,7 +540,7 @@ do--json if a then return b else - LOG.print(text.jsonError,"warn") + LOG.print(text.jsonError..": "..(b or"uknErr"),"warn") return end end