自己写一个显示函数
function show_table(t, level)
local show = ''
local temp = ''
local space = string.rep(' ', (level-1)*4)
local sapce4 = string.rep(' ', 4)
if(type(t) ~= 'table') then
return 'error: params t is not a table.'
else
show = show .. tostring(t) .. "{\n" .. space
for k,v in pairs(t) do
if type(v) == 'table' then
temp = show_table(v, level+1)
elseif(type(v) == 'string') then
temp = '\"' .. tostring(v) .. '\"'
else
temp = tostring(v)
end
show = show .. sapce4 .. tostring(k) .. " = " .. temp .. ",\n" .. space
end
show = show .. "}"
end
return show
end
apisix有一个更简单的方法
core.json.encode(status)