projects
/
project
/
luci.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
(from parent 1:
d2638a7
)
Merge pull request #402 from NeoRaider/json-empty-object
405/head
406/head
407/head
408/head
author
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 10 Jun 2015 08:20:49 +0000
(10:20 +0200)
committer
Jo-Philipp Wich
<jow@openwrt.org>
Wed, 10 Jun 2015 08:20:49 +0000
(10:20 +0200)
luci-lib-json: ignore null keys to allow encoding empty objects
libs/luci-lib-json/luasrc/json.lua
patch
|
blob
|
history
diff --git
a/libs/luci-lib-json/luasrc/json.lua
b/libs/luci-lib-json/luasrc/json.lua
index
416b25f
..
f7b57f9
100644
(file)
--- 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("}")