Module:JSONPageList

-- Demo for T332484 require( 'strict' ) local r={} --local lang="en" local site="enwiki" local siteprefix="en:"

function r.table(pagename, fields) if type(pagename) == "table" then pagename, fields = pagename.args[1], pagename.args[2] end local content=mw.title.new(pagename):getContent content=mw.text.jsonDecode(content) local fields=content.fields local items=content.items for i, v in ipairs( items ) do       if type(v) == "string" then items[i]={_qid=v} end end local result=mw.html.create("table"):attr( 'class', 'wikitable' ) local heading=result:tag("tr") local cell=heading:tag("th") cell:wikitext("item") for i, v in ipairs( items ) do   	local row=result:tag("tr") local cell=row:tag("td") local qid=v._qid local sitelink=mw.wikibase.getSitelink(qid,site) local label=mw.wikibase.getLabel(qid) if sitelink then cell:wikitext(..label..) else cell:wikitext(..label..) end end return tostring( result ) end

return r