Модуль:GetField: различия между версиями
Pok (обсуждение | вклад) Нет описания правки |
Pok (обсуждение | вклад) Нет описания правки |
||
| Строка 220: | Строка 220: | ||
local key = (prefix == "" and tostring(k) or prefix .. "." .. tostring(k)) | local key = (prefix == "" and tostring(k) or prefix .. "." .. tostring(k)) | ||
if type(v) == "table" then | local okJson, json = pcall(mw.text.jsonEncode, v) | ||
if okJson and json == "null" then | |||
parts[#parts + 1] = key .. "=null" | |||
local ok, | else | ||
if type(v) == "table" then | |||
if next(v) == nil then | |||
elseif is_array(v) then | |||
local ok, arrJson = pcall(mw.text.jsonEncode, v) | |||
if ok and arrJson then | |||
parts[#parts + 1] = key .. "=" .. to_nowiki(arrJson) | |||
end | |||
else | |||
local ok, objJson = pcall(mw.text.jsonEncode, v) | |||
if ok and objJson then | |||
parts[#parts + 1] = key .. "=" .. to_nowiki(objJson) | |||
end | |||
walk(v, key) | |||
end | end | ||
else | else | ||
local | local fv = format_value(v) | ||
if | if fv ~= "" then | ||
parts[#parts + 1] = key .. "=" .. | parts[#parts + 1] = key .. "=" .. fv | ||
end | end | ||
end | end | ||
end | end | ||