Talk:binser
Is here any inbuilt serialize function? --Darkfrei (talk) 20:45, 20 January 2021 (CET)
For example (my code)
serialize = function (tabl)
local str = ''
for i, v in pairs (tabl) do
local pr = (type(i)=="string") and i..'=' or ''
if type (v) == "table" then
str = str .. pr..'{'..serialize(v)..'},'
elseif type (v) == "string" then
str = str .. pr..'"'..tostring(v)..'",'
else
str = str .. pr..tostring(v)..','
end
end
str = str:sub(1, -2) -- remove last comma
return str
end
local a = {1,2,3, a='b', c={"d",e="e"},d={{1},{2}}, f={}}
print (serialize(a)) -- 1,2,3,d={{1},{2}},f={},a="b",c={"d",e="e"}
--Darkfrei (talk) 17:57, 21 February 2021 (CET)
As I know, you can use love.data.pack and love.data.unpack --Andlac028 (talk) 16:22, 25 February 2021 (CET)