Module:GetJSON: Difference between revisions
From AlternateWiki
Content added Content deleted
No edit summary |
No edit summary |
||
Line 31: | Line 31: | ||
return value |
return value |
||
end |
|||
-- Function to check if a table is an array |
|||
local function isArray(table) |
|||
local count = 0 |
|||
for k, _ in pairs(table) do |
|||
if type(k) ~= "number" then |
|||
return false |
|||
end |
|||
count = count + 1 |
|||
end |
|||
return #table == count |
|||
end |
end |
||
Line 38: | Line 50: | ||
if value ~= nil then |
if value ~= nil then |
||
if type(value) == "table" then |
if type(value) == "table" then |
||
if isArray(value) then |
|||
local str = "" |
|||
for _, v in ipairs(value) do |
|||
str = str .. v .. ";" |
|||
end |
|||
⚫ | |||
else |
|||
local str = "" |
|||
for k, _ in pairs(value) do |
|||
str = str .. k .. ";" |
|||
end |
|||
return frame:preprocess(str:sub(1, -2)) |
|||
end |
end |
||
⚫ | |||
end |
end |
||
return frame:preprocess(value) |
return frame:preprocess(value) |