Module:GetJSON: Difference between revisions
From AlternateWiki
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
-- 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[
-- 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[
-- Return keys of the table
local str = ""
Line 109 ⟶ 105:
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
|