NestedTable = {
["TestVar1"] = 1,
["TestTablePath"] = {
["TestTablePool1"] = {2, 3},
["TestTablePool2"] = "This is a test string",
},
HeheHaha = {
bing_bong = "bing bong"
},
TestBoi = {},
}
local function table_extend(tbl, element)
local copy = {table.unpack(tbl)}
table.insert(copy, element)
return copy
end
function flatten(value, path, pool)
path = path or {"root"}
pool = pool or {}
pool[path] = value
if type(value) == "table" then
for i, v in pairs(value) do
flatten(v, table_extend(path, i), pool)
end
end
return pool
end
local pool = flatten(NestedTable)
for i, v in pairs(pool) do
if type(v) == "table" then v = "[table]" end
print(table.concat(i, "/") .. " -> " .. v)
end
To embed this project on your website, copy the following code and paste it into your website's HTML: