diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2015-06-10 10:20:49 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2015-06-10 10:20:49 +0200 |
commit | edf0f4f549983f93ee13223cf614393e7809cf49 (patch) | |
tree | 3733556468a2e2f4020573ce6974faf2ada09370 /libs/luci-lib-json/luasrc/json.lua | |
parent | d2638a7a0ebc4d0e7ea394a74bd41fd0762200d8 (diff) | |
parent | 304eec2ebaf983fd067e5ae719f8ec023aad8b30 (diff) |
Merge pull request #402 from NeoRaider/json-empty-object
luci-lib-json: ignore null keys to allow encoding empty objects
Diffstat (limited to 'libs/luci-lib-json/luasrc/json.lua')
-rw-r--r-- | libs/luci-lib-json/luasrc/json.lua | 12 |
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 416b25faa5..f7b57f916c 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("}") |