[added] quoted strings in tablex.stringify; todo consider moving it to stringx actually, as it works for non-table types, maybe as stringx.pretty...

This commit is contained in:
Max Cahill 2020-04-17 10:34:39 +10:00
parent f6a2c9834f
commit 6bf6113dc2

View File

@ -276,7 +276,12 @@ function tablex.stringify(t)
--just use tostring --just use tostring
local mt = getmetatable(t) local mt = getmetatable(t)
if type(t) ~= "table" or mt and mt.__tostring then if type(t) ~= "table" or mt and mt.__tostring then
return tostring(t) local s = tostring(t)
--quote strings
if type(t) == "string" then
s = '"' .. s .. '"'
end
return s
end end
--otherwise, collate into member chunks --otherwise, collate into member chunks