Модуль:Сущность: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 227: | Строка 227: | ||
local ok, data = pcall(mw.text.jsonDecode, expanded) | local ok, data = pcall(mw.text.jsonDecode, expanded) | ||
if ok | if not ok or type(data) ~= "table" then | ||
return | return "" | ||
end | end | ||
if data.card == nil then | |||
local cardKeys = {} | |||
local seen = {} | |||
for base, labels in pairs(data) do | |||
if type(base) == "string" and base ~= "card" and base:sub(1, 4) == "card" and type(labels) == "table" then | |||
for _, lab in ipairs(labels) do | |||
if not seen[lab] then | |||
seen[lab] = true | |||
table.insert(cardKeys, lab) | |||
end | |||
end | |||
end | |||
end | |||
data.card = cardKeys | |||
end | |||
return data | |||
end | end | ||