summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-06-10 10:20:49 +0200
committerJo-Philipp Wich <jow@openwrt.org>2015-06-10 10:20:49 +0200
commitedf0f4f549983f93ee13223cf614393e7809cf49 (patch)
tree3733556468a2e2f4020573ce6974faf2ada09370
parentd2638a7a0ebc4d0e7ea394a74bd41fd0762200d8 (diff)
parent304eec2ebaf983fd067e5ae719f8ec023aad8b30 (diff)
Merge pull request #402 from NeoRaider/json-empty-object
luci-lib-json: ignore null keys to allow encoding empty objects
-rw-r--r--libs/luci-lib-json/luasrc/json.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/libs/luci-lib-json/luasrc/json.lua b/libs/luci-lib-json/luasrc/json.lua
index 416b25faa..f7b57f916 100644
--- a/libs/luci-lib-json/luasrc/json.lua
+++ b/libs/luci-lib-json/luasrc/json.lua
@@ -149,11 +149,13 @@ function Encoder.parse_iter(self, obj)
local first = true
for key, entry in pairs(obj) do
- first = first or self:put(",")
- first = first and false
- self:parse_string(tostring(key))
- self:put(":")
- self:dispatch(entry)
+ if key ~= null then
+ first = first or self:put(",")
+ first = first and false
+ self:parse_string(tostring(key))
+ self:put(":")
+ self:dispatch(entry)
+ end
end
self:put("}")