[vlc-commits] clean up json output
Rob Jonson
git at videolan.org
Wed Oct 5 18:51:31 CEST 2011
vlc | branch: master | Rob Jonson <rob at hobbyistsoftware.com> | Wed Sep 28 13:05:16 2011 +0100| [1b43a4641d0272102153d13e4d8ced5d1a0a80ce] | committer: Jean-Baptiste Kempf
clean up json output
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1b43a4641d0272102153d13e4d8ced5d1a0a80ce
---
share/lua/intf/modules/httprequests.lua | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/share/lua/intf/modules/httprequests.lua b/share/lua/intf/modules/httprequests.lua
index 9e549c4..bbef569 100644
--- a/share/lua/intf/modules/httprequests.lua
+++ b/share/lua/intf/modules/httprequests.lua
@@ -196,9 +196,28 @@ function xmlString(s)
end
end
+--dkjson outputs numbered tables as arrays
+--so we don't need the array indicators
+function removeArrayIndicators(dict)
+ local newDict=dict
+ for k,v in pairs(dict) do
+ if (type(v)=="table") then
+ local arrayEntry=v._array
+ if arrayEntry then
+ v=arrayEntry
+ end
+
+ dict[k]=removeArrayIndicators(v)
+ end
+ end
+
+ return newDict
+end
printTableAsJson = function (dict)
+ dict=removeArrayIndicators(dict)
+
local output=dkjson.encode (dict, { indent = true })
print(output)
end
More information about the vlc-commits
mailing list