Module:Definitions: Difference between revisions
From SpiritVale Wiki
More actions
No edit summary Tags: Reverted Mobile edit Mobile web edit |
No edit summary Tags: Reverted Mobile edit Mobile web edit |
||
| Line 67: | Line 67: | ||
if DB ~= nil then return DB end | if DB ~= nil then return DB end | ||
-- Preferred: Scribunto JSON loader (reliable for Module:*.json pages) | |||
local ok, obj = pcall(mw.loadJsonData, DATA_TITLE) | |||
if ok and type(obj) == "table" then | |||
DB = obj | |||
return DB | |||
end | |||
-- Fallback: raw content + jsonDecode (kept for safety) | |||
local title = mw.title.new(DATA_TITLE) | local title = mw.title.new(DATA_TITLE) | ||
if not title then | if not title then | ||
| Line 79: | Line 87: | ||
end | end | ||
local | local ok2, obj2 = pcall(mw.text.jsonDecode, raw) | ||
if not | if not ok2 or type(obj2) ~= "table" then | ||
DB = {} | DB = {} | ||
return DB | return DB | ||
end | end | ||
DB = | DB = obj2 | ||
return DB | return DB | ||
end | end | ||