util/serialization.lua

changeset 2222
81b4e738e4d3
parent 2151
603134825bdb
child 2923
b7049746bd29
equal deleted inserted replaced
2216:9e1c6b6a2ee4 2222:81b4e738e4d3
33 if type(o) == "number" then 33 if type(o) == "number" then
34 func(t, tostring(o)); 34 func(t, tostring(o));
35 elseif type(o) == "string" then 35 elseif type(o) == "string" then
36 func(t, (("%q"):format(o):gsub("\\\n", "\\n"))); 36 func(t, (("%q"):format(o):gsub("\\\n", "\\n")));
37 elseif type(o) == "table" then 37 elseif type(o) == "table" then
38 if next(o) then 38 if next(o) ~= nil then
39 func(t, "{\n"); 39 func(t, "{\n");
40 for k,v in pairs(o) do 40 for k,v in pairs(o) do
41 func(t, indent(ind)); 41 func(t, indent(ind));
42 func(t, "["); 42 func(t, "[");
43 func(t, basicSerialize(k)); 43 func(t, basicSerialize(k));

mercurial