From: Jo-Philipp Wich Date: Wed, 10 Jun 2015 08:20:49 +0000 (+0200) Subject: Merge pull request #402 from NeoRaider/json-empty-object X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=edf0f4f549983f93ee13223cf614393e7809cf49;hp=d2638a7a0ebc4d0e7ea394a74bd41fd0762200d8 Merge pull request #402 from NeoRaider/json-empty-object luci-lib-json: ignore null keys to allow encoding empty objects --- 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("}")