2021-06-03 13:00:02 +00:00
|
|
|
-- lua-cjson's is_array by Mark Pulford
|
2021-11-13 08:31:32 +00:00
|
|
|
function auIsArray(table)
|
2021-06-03 13:00:02 +00:00
|
|
|
local max = 0
|
|
|
|
local count = 0
|
|
|
|
|
2022-01-17 19:40:31 +00:00
|
|
|
if (type(table) ~= "table") then
|
2021-06-03 13:00:02 +00:00
|
|
|
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
|
2021-11-13 08:31:32 +00:00
|
|
|
end
|