ignore json parsing error

This commit is contained in:
Er2 2022-01-23 17:05:18 +03:00
parent 30f7203c5f
commit 4dec8003ed
1 changed files with 3 additions and 3 deletions

View File

@ -72,7 +72,7 @@ function tools.req(url, par, f, dbg)
if fr then if fr then
par[ft] = { par[ft] = {
filename = fn, filename = fn,
data = fr:read '*a' data = fr:read '*a'
} }
fr:close() fr:close()
else par[ft] = fn end else par[ft] = fn end
@ -84,8 +84,8 @@ function tools.req(url, par, f, dbg)
if dbg then print(url, succ, res, par) if dbg then print(url, succ, res, par)
-- dump(par)) -- dump(par))
end end
res = json.decode(res or '{}') local s, res = pcall(json.decode, res or '{}')
if not succ or not res then return {}, false end if not s or not succ or not res then return {}, false end
return res, true return res, true
end end