Module:GetJSON: Difference between revisions

From AlternateWiki
207 bytes removed ,  1 month ago
no edit summary
No edit summary
No edit summary
Line 31:
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
 
Line 50 ⟶ 38:
if value ~= nil then
if type(value) == "table" then
if isArray(value)frame.args[4] == "keys" then
-- Return the keys of the table
local str = ""
for _k, v_ in ipairspairs(value) do
str = str .. vk .. ";"
end
return frame:preprocess(str:sub(1, -2))
else
-- Return the values of the table
local str = ""
for k_, _v in pairs(value) do
str = str .. kv .. ";"
end
return frame:preprocess(str:sub(1, -2))
Cookies help us deliver our services. By using our services, you agree to our use of cookies.