[vlc-devel] [PATCH 4/6] clean up json output
Rob Jonson
rob at hobbyistsoftware.com
Wed Sep 28 14:05:16 CEST 2011
---
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
--
1.7.5
More information about the vlc-devel
mailing list