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
|
|
|
|
|
|
|
|
if (type(object) ~= "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
|
2021-11-13 08:31:32 +00:00
|
|
|
end
|