aboutsummaryrefslogtreecommitdiffstats
path: root/util/serialization.lua
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-11-23 21:02:06 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-11-23 21:02:06 +0500
commit82c595c85bd5ea8bf9dc116e3e1b9f01a56f8619 (patch)
treeb562c8f53fe7471ad6d62bccc9f3a72e3cfa1e0e /util/serialization.lua
parenta1cca576be8eeb34d63963f14785445d99bc355f (diff)
parent5b41760cecdfd2db66b84ce92454dd61e7f1341b (diff)
downloadprosody-82c595c85bd5ea8bf9dc116e3e1b9f01a56f8619.tar.gz
prosody-82c595c85bd5ea8bf9dc116e3e1b9f01a56f8619.zip
Merged with 0.6.
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..07a099c9 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) 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