Модуль:GetField: различия между версиями

мНет описания правки
Нет описания правки
Строка 219: Строка 219:
             local v = tbl[k]
             local v = tbl[k]
             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
             if type(v) == "table" then
                 if next(v) == nil then
                 if next(v) == nil then
Строка 234: Строка 235:
                 end
                 end
             else
             else
                 parts[#parts + 1] = key .. "=" .. tostring(v)
                 local okJson, json = pcall(mw.text.jsonEncode, v)
                if okJson and json == "null" then
                    parts[#parts + 1] = key .. "=null"
                else
                    parts[#parts + 1] = key .. "=" .. tostring(v)
                end
             end
             end
         end
         end
Строка 315: Строка 321:
                     if is_array(v) then
                     if is_array(v) then
                         for _, item in ipairs(v) do
                         for _, item in ipairs(v) do
                             if tostring(item) == target then
                             if format_value(item) == target then
                                 matches[#matches + 1] = idKey
                                 matches[#matches + 1] = idKey
                                 break
                                 break
Строка 322: Строка 328:
                     else
                     else
                         for _, item in pairs(v) do
                         for _, item in pairs(v) do
                             if tostring(item) == target then
                             if format_value(item) == target then
                                 matches[#matches + 1] = idKey
                                 matches[#matches + 1] = idKey
                                 break
                                 break
Строка 329: Строка 335:
                     end
                     end
                 else
                 else
                     if tostring(v) == target then
                     if format_value(v) == target then
                         matches[#matches + 1] = idKey
                         matches[#matches + 1] = idKey
                     end
                     end
Строка 386: Строка 392:
                     if is_array(v) then
                     if is_array(v) then
                         for _, item in ipairs(v) do
                         for _, item in ipairs(v) do
                             if tostring(item) == target then
                             if format_value(item) == target then
                                 matches[#matches + 1] = idKey
                                 matches[#matches + 1] = idKey
                                 break
                                 break
Строка 393: Строка 399:
                     else
                     else
                         for _, item in pairs(v) do
                         for _, item in pairs(v) do
                             if tostring(item) == target then
                             if format_value(item) == target then
                                 matches[#matches + 1] = idKey
                                 matches[#matches + 1] = idKey
                                 break
                                 break
Строка 400: Строка 406:
                     end
                     end
                 else
                 else
                     if tostring(v) == target then
                     if format_value(v) == target then
                         matches[#matches + 1] = idKey
                         matches[#matches + 1] = idKey
                     end
                     end