Module:ProfessionList: Difference between revisions

179 bytes removed ,  Yesterday at 22:55
no edit summary
mNo edit summary
No edit summary
Line 72:
for _, page in ipairs(pages) do
-- first iterate through activities
-- combine the activityJSON and recipeJSON into one table
local JSONs = {}
if page.activityJSON ~= nil then
if type(page.activityJSON)=='string' then
tablepage.insert(JSONs,recipeJSON = { page.activityJSON) }
elseend
for _, jsonJSON in ipairs(page.activityJSON) do
local item = mw.text.jsonDecode(JSON)
json.type = 'activity'
item.page = page.pageName
table.insert(JSONs,json)
item.pageImage = page.pageImage
end
jsonitem.type = 'activity'
table.insert(JSONsoutput,jsonitem)
end
end
-- same iteration through recipes
if page.recipeJSON ~= nil then
if type(page.recipeJSON)=='string' then
tablepage.insert(JSONs,recipeJSON = { page.recipeJSON) }
else
for _, json in page.recipeJSON do
json.type = 'recipe'
table.insert(JSONs,json)
end
end
for _, jsonJSON in ipairs(page.recipeJSON) do
end
-- iterate through combined list of JSONs and extract the info
if JSONs[1] ~= nil then
for _, JSON in ipairs(JSONs) do
--decode the JSON to a Lua table, add data from the page that had it
local item = mw.text.jsonDecode(JSON)
item.page = page.pageName
item.pageImage = page.pageImage
jsonitem.type = 'recipe'
--insert into output table
table.insert(output,item)
end
end
end
11,305

edits