diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-18 19:01:04 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-01-22 15:01:50 +0100 |
commit | 390c4bd5a7e1e53bc9e765a3b5ee8f59f46d5598 (patch) | |
tree | f3025e84330d0ba7aba3bd6d7eaff02c25f7fce5 /modules/luci-base | |
parent | 61a9a58efcb27e2860cef804f04c9c4ba4ceb168 (diff) |
luci-base: use serialize_json() in luci.http
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/luasrc/http.lua | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/modules/luci-base/luasrc/http.lua b/modules/luci-base/luasrc/http.lua index a5329e51d..5e1d73e3a 100644 --- a/modules/luci-base/luasrc/http.lua +++ b/modules/luci-base/luasrc/http.lua @@ -285,40 +285,5 @@ urlencode = protocol.urlencode --- Send the given data as JSON encoded string. -- @param data Data to send function write_json(x) - if x == nil then - write("null") - elseif type(x) == "table" then - local k, v - if type(next(x)) == "number" then - write("[ ") - for k, v in ipairs(x) do - write_json(v) - if next(x, k) then - write(", ") - end - end - write(" ]") - else - write("{ ") - for k, v in pairs(x) do - write("%q: " % k) - write_json(v) - if next(x, k) then - write(", ") - end - end - write(" }") - end - elseif type(x) == "number" or type(x) == "boolean" then - if (x ~= x) then - -- NaN is the only value that doesn't equal to itself. - write("Number.NaN") - else - write(tostring(x)) - end - else - write('"%s"' % tostring(x):gsub('["%z\1-\31]', function(c) - return '\\u%04x' % c:byte(1) - end)) - end + util.serialize_json(x, write) end |