23 lines
449 B
Lua
23 lines
449 B
Lua
-- lua-cjson's is_array by Mark Pulford
|
|
function auIsArray(table)
|
|
local max = 0
|
|
local count = 0
|
|
|
|
if (type(table) ~= "table") then
|
|
return false
|
|
end
|
|
|
|
for k, v in pairs(table) do
|
|
if type(k) == "number" then
|
|
if k > max then max = k end
|
|
count = count + 1
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
if max > count * 2 then
|
|
return false
|
|
end
|
|
|
|
return max > 0
|
|
end |