From: Jo-Philipp Wich Date: Thu, 28 Aug 2008 16:17:42 +0000 (+0000) Subject: * luci/libs: util: improve table handling and support mixed tables in serialize_data() X-Git-Tag: 0.8.0~264 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2975bb66a61e2f5c86c8ee9701830e40d8c1ab82;p=oweals%2Fluci.git * luci/libs: util: improve table handling and support mixed tables in serialize_data() --- diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 2ede71a26..2a7e70453 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -437,11 +437,17 @@ function _serialize_table(t, seen) seen[t] = true local data = "" + for i = 1, #t do + local v = serialize_data(t[i], seen) + data = data .. ( #data > 0 and ", " or "" ) .. v + end for k, v in pairs(t) do - k = serialize_data(k, seen) - v = serialize_data(v, seen) - data = data .. ( #data > 0 and ", " or "" ) .. - '[' .. k .. '] = ' .. v + if type(k) ~= "number" then + k = serialize_data(k, seen) + v = serialize_data(v, seen) + data = data .. ( #data > 0 and ", " or "" ) .. + '[' .. k .. '] = ' .. v + end end return data end