Module:Lua json: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
local content = jsonPage:getContent() | local content = jsonPage:getContent() | ||
local jsonData = mw.text.jsonDecode(content) | local jsonData = mw.text.jsonDecode(content) | ||
if jsonData and jsonData.schemas and jsonData.schemas. | if jsonData and jsonData.schemas and jsonData.schemas.Dataset then | ||
return jsonData.schemas.Dataset.date | return jsonData.schemas.Dataset.date | ||
else | else |
Latest revision as of 10:33, 2 May 2024
Documentation for this module may be created at Module:Lua json/doc
local p = {}
function p.getProjectData()
local jsonPage = mw.title.new("Entry:Datasets/Dataset")
if jsonPage and jsonPage.exists then
local content = jsonPage:getContent()
local jsonData = mw.text.jsonDecode(content)
if jsonData and jsonData.schemas and jsonData.schemas.Dataset then
return jsonData.schemas.Dataset.date
else
return "Error: Invalid JSON structure"
end
else
return "Error: JSON page does not exist"
end
end
return p