]> git.sesse.net Git - vlc/commitdiff
clean up json output
authorRob Jonson <rob@hobbyistsoftware.com>
Wed, 28 Sep 2011 12:05:16 +0000 (13:05 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 5 Oct 2011 16:51:15 +0000 (18:51 +0200)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
share/lua/intf/modules/httprequests.lua

index 9e549c4a08d5048e0981b9ce5b00717d63d026bb..bbef5695815854ba41be7f325daa011fda491df9 100644 (file)
@@ -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