Advertisement

APISIX插件如何打印和处理table数据

阅读量:

本文件为个人博客系统文档的存档版本,创作者:小游,创作者博客地址:点击访问

自己写一个显示函数

复制代码
    ---,显示table时递归调用的函数
    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
            --递归显示table
            if type(v) == 'table' then
                temp = show_table(v, level+1)
            elseif(type(v) == '

全部评论 (0)

还没有任何评论哟~