Created
December 21, 2020 16:35
-
-
Save Torte446/cad94cf33bf06a70ba96ad3c9f1938ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tab2str(tab) | |
local s = "{" | |
for i,v in pairs(tab) do | |
if type(v) == "table" then | |
s = s.."{" | |
for it,vt in pairs(v) do | |
if type(vt) == "table" then | |
s = s.."{" | |
s = s..stringall.table(vt) | |
if it ~= #v then | |
s = s.."," | |
end | |
elseif it ~= #v then | |
if type(vt) == "string" then | |
s = s..'"'..vt..'"'.."," | |
else | |
s = s..tostring(vt).."," | |
end | |
else | |
s = s..tostring(vt).."}" | |
end | |
end | |
elseif i ~= #tab then | |
if type(v) == "string" then | |
s = s..'"'..v..'"'.."," | |
else | |
s = s..tostring(v).."," | |
end | |
elseif type(v) == "string" then | |
s = s..'"'..v..'"'.."}" | |
else | |
s = s..tostring(v).."}" | |
end | |
end | |
return s; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tab2str({1,2,{4,5,{6,7},"ab","cd"}})
will return {1,2,{4,5,{6,7},"ab","cd"}}