Module:Indicator datasets table: Difference between revisions

From Visual Data Wiki
Jump to navigation Jump to search
Created page with "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: J..."
 
No edit summary
Line 1: Line 1:
local p = {}
local p = {}


function p.getProjectData()
function p.getDatasets()
     local jsonPage = mw.title.new("Entry:Datasets/Dataset")
     local jsonPage = mw.title.new("Entry:Datasets/Dataset")
     if jsonPage and jsonPage.exists then
     if jsonPage and jsonPage.exists then

Revision as of 10:41, 2 May 2024

Documentation for this module may be created at Module:Indicator datasets table/doc

local p = {}

function p.getDatasets()
    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