"bacu-saupu:JSONObject" misumad laeday sasizuma
刪去的內容 新增的內容
Imported from w:zh:Module:JSONObject via importer.js |
(inayi’ sasizuma)
|
i 2020年2月3日 (sakacacay a demied nu lipay) 12:07 a sabaluhay masumad
可在bacu-saupu:JSONObject/doc建立此模組的說明文件
local p = {}
function p._get( frame, args )
local default = args["default"]
local title = args[1]
local page = mw.title.new( title )
local content = page:getContent()
if content == nil then
return default
end
local object = mw.text.jsonDecode( content )
local idx = 2
while args[idx] ~= nil do
object = object[args[idx]]
if object == nil and default ~= nil then
return default
end
idx = idx + 1
end
if type(object) == "table" then
return default
end
return object
end
function p.get( frame )
local args = frame:getParent().args
result = p._get( frame, args )
if args["preprocess"] then
result = frame:preprocess( result )
end
return result
end
return p