diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2008-08-28 16:17:42 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2008-08-28 16:17:42 +0000 |
commit | 2975bb66a61e2f5c86c8ee9701830e40d8c1ab82 (patch) | |
tree | 16f193ed4807846f7ac98fc7ac3d58dbbdac7d08 /libs | |
parent | b3d63252e772f98a269a241c9f9f995f216efb84 (diff) |
* luci/libs: util: improve table handling and support mixed tables in serialize_data()
Diffstat (limited to 'libs')
-rw-r--r-- | libs/core/luasrc/util.lua | 14 |
1 files changed, 10 insertions, 4 deletions
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 |