参考:https://www.likecs.com/show-308547984.html
function print_r(t)local print_r_cache={}local function sub_print_r(t,indent)if (type(t)=="table") thenfor pos,val in pairs(t) doif (type(val)=="table") thenprint(indent.."["..pos.."] = "..tostring(t).." {")sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))print(indent..string.rep(" ",string.len(pos)+6).."}")elseif (type(val)=="string") thenprint(indent.."["..pos..'] = "'..val..'"')elseprint(indent.."["..pos.."] = "..tostring(val))endendelseprint(indent..tostring(t))endendif (type(t)=="table") thenprint(tostring(t).." {")sub_print_r(t," ")print("}")elsesub_print_r(t," ")endprint()
end
local record1 = {["key"] = 1,["value"] = 2
}
local record2 = {["key"] = 3,["value"] = 4
}
local record3 = {record1,record2}
local record = {["where"] = record3}
print_r(record)