To edit the documentation or categories for this module, click here.
This module is used in more places than its WhatLinksHere shows!
It may be used in gadgets, external Python scripts, or other places unable to be shown in WhatLinksHere. Please do not delete it just because it appears unused! |
local util_args = require('Module:ArgsUtil')
-- small wrapper to retieve string representation of a json version of a data table
-- intended to be called via the expandtemplates api action
-- this should not be used internally at all
-- please do not delete even if it's not used anywhere
local p = {}
function p.main(frame)
local args = util_args.merge()
tbl = require(('Module:%snames'):format(args[1]))
-- if a table (e.g. Rolenames) has entries for both the integer & string versions of a number, we can't jsonEncode
-- so let's just get rid of all string keys in cases like this
-- realistically, this will not often be a problem and we aren't gonna care about the chance that
-- ipairs may be not well-defined (i.e. there maybe skipped indices)
for i in ipairs(tbl) do
tbl[tostring(i)] = nil
end
str = mw.text.jsonEncode(tbl)
return str
end
return p