Module:GetJSON: Difference between revisions
From AlternateWiki
Content added Content deleted
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
Line 7:
local m = {}
-- Load JSON data from the first argument passed to the module
if
m.root = mw.text.jsonDecode(frame.args[1])
else
Line 81:
-- Split the key provided in the second argument
local keys = splitKey(frame.args[
-- Get the value from the nested table using the keys
local value = getValueByKeys(m.root, keys)
Line 90:
if type(value) == "table" then
-- If the fourth parameter is "keys"
if frame.args[
-- Return keys of the table
local str = ""
Line 109:
else
-- If the third argument is not nil, return it
if frame.args[
return frame.args[
else
return "" -- Return an empty string if no value is found
|