Module:SS Medals

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 20:06, 2 June 2024 by Morganstedmanms (talk | contribs) (Created page with "-- Module:JoJoWiki local p = {} local json = require("json") function p.getTitle(id) -- Load JSON data from the page "JoJo Wiki:SS Medals" local jsonData = mw.title.new("JoJo Wiki:SS Medals"):getContent() -- Parse JSON data local data = json.decode(jsonData) -- Search for the entry with the given ID for _, entry in ipairs(data) do if entry.id == id then return entry.title end end return nil end...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:SS Medals/doc

-- Module:JoJoWiki
local p = {}

local json = require("json")

function p.getTitle(id)
    -- Load JSON data from the page "JoJo Wiki:SS Medals"
    local jsonData = mw.title.new("JoJo Wiki:SS Medals"):getContent()
    
    -- Parse JSON data
    local data = json.decode(jsonData)
    
    -- Search for the entry with the given ID
    for _, entry in ipairs(data) do
        if entry.id == id then
            return entry.title
        end
    end
    
    return nil
end

return p