Module:GetJSON: Difference between revisions

From AlternateWiki
Content added Content deleted
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
Line 17: Line 17:
local value = root
local value = root
for _, key in ipairs(keys) do
for _, key in ipairs(keys) do
if key:sub(1, 1) == "#" then
if tonumber(key) then
key = tonumber(key:sub(2))
key = tonumber(key)
if not key then
return nil
end
local dictKeys = {}
for dictKey in pairs(value) do
table.insert(dictKeys, dictKey)
end
table.sort(dictKeys)
key = dictKeys[key]
end
end
Line 52: Line 43:
if type(value) == "table" then
if type(value) == "table" then
if frame.args[4] == "keys" then
if frame.args[4] == "keys" then
-- Return the keys of the table if requested
-- Return the keys of the table
local str = ""
local str = ""
for k, _ in pairs(value) do
for k, _ in pairs(value) do