aboutsummaryrefslogtreecommitdiffstats
path: root/util/serialization.lua
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2009-11-29 21:33:37 +0100
committerTobias Markmann <tm@ayena.de>2009-11-29 21:33:37 +0100
commitf91009f78a46ad74aa62ff487fa297c06a1ae6a3 (patch)
tree8ef6302fc66fdc48b4f34f58c3bea877d7ee6bee /util/serialization.lua
parent8db68f17623ad29b25c6b5d757a2fb0b3d3005c6 (diff)
parent8fcbba4b0fccb299121083d97cab065e51fba9d1 (diff)
downloadprosody-f91009f78a46ad74aa62ff487fa297c06a1ae6a3.tar.gz
prosody-f91009f78a46ad74aa62ff487fa297c06a1ae6a3.zip
Merge with tip.
Diffstat (limited to 'util/serialization.lua')
-rw-r--r--util/serialization.lua31
1 files changed, 18 insertions, 13 deletions
diff --git a/util/serialization.lua b/util/serialization.lua
index c2bbbb8d..7071d3f7 100644
--- a/util/serialization.lua
+++ b/util/serialization.lua
@@ -13,6 +13,7 @@ local t_insert = table.insert;
local t_concat = table.concat;
local error = error;
local pairs = pairs;
+local next = next;
local debug_traceback = debug.traceback;
local log = require "util.logger".init("serialization");
@@ -34,21 +35,25 @@ local function _simplesave(o, ind, t, func)
elseif type(o) == "string" then
func(t, (("%q"):format(o):gsub("\\\n", "\\n")));
elseif type(o) == "table" then
- func(t, "{\n");
- for k,v in pairs(o) do
- func(t, indent(ind));
- func(t, "[");
- func(t, basicSerialize(k));
- func(t, "] = ");
- if ind == 0 then
- _simplesave(v, 0, t, func);
- else
- _simplesave(v, ind+1, t, func);
+ if next(o) ~= nil then
+ func(t, "{\n");
+ for k,v in pairs(o) do
+ func(t, indent(ind));
+ func(t, "[");
+ func(t, basicSerialize(k));
+ func(t, "] = ");
+ if ind == 0 then
+ _simplesave(v, 0, t, func);
+ else
+ _simplesave(v, ind+1, t, func);
+ end
+ func(t, ";\n");
end
- func(t, ",\n");
+ func(t, indent(ind-1));
+ func(t, "}");
+ else
+ func(t, "{}");
end
- func(t, indent(ind-1));
- func(t, "}");
elseif type(o) == "boolean" then
func(t, (o and "true" or "false"));
else