Module:GetJSON: Difference between revisions

From AlternateWiki
102 bytes removed ,  10 days ago
no edit summary
No edit summary
Tag: Reverted
No edit summary
Tag: Manual revert
 
Line 7:
local m = {}
-- Load JSON data from the first argument passed to the module
ifm.root = mw.loadJsonData(frame.args[1] == "yes" then)
m.root = mw.text.jsonDecode(frame.args[2])
else
m.root = mw.loadJsonData(frame.args[2])
end
-- Function to split a key string by "."
local function splitKey(key)
Line 81 ⟶ 77:
 
-- Split the key provided in the second argument
local keys = splitKey(frame.args[32])
-- Get the value from the nested table using the keys
local value = getValueByKeys(m.root, keys)
Line 90 ⟶ 86:
if type(value) == "table" then
-- If the fourth parameter is "keys"
if frame.args[54] == "keys" then
-- Return keys of the table
local str = ""
Line 109 ⟶ 105:
else
-- If the third argument is not nil, return it
if frame.args[43] ~= nil then
return frame.args[43]
else
return "" -- Return an empty string if no value is found
Cookies help us deliver our services. By using our services, you agree to our use of cookies.