webmcp

changeset 556:c228db239964

Only treat tables without metatable as array
author jbe
date Tue Feb 18 18:15:42 2020 +0100 (9 months ago)
parents 16197a40c7a9
children c839cbd66598
files libraries/mondelefant/mondelefant_atom_connector.lua
line diff
     1.1 --- a/libraries/mondelefant/mondelefant_atom_connector.lua	Mon Feb 10 20:47:58 2020 +0100
     1.2 +++ b/libraries/mondelefant/mondelefant_atom_connector.lua	Tue Feb 18 18:15:42 2020 +0100
     1.3 @@ -113,7 +113,7 @@
     1.4    end
     1.5  end
     1.6  
     1.7 -input_converters["table"] = function(conn, value, rawtext_mode)
     1.8 +input_converters["rawtable"] = function(conn, value, rawtext_mode)
     1.9    -- treat tables as arrays
    1.10    local parts = { "{" }
    1.11    for i, v in ipairs(value) do
    1.12 @@ -213,6 +213,16 @@
    1.13    if value == nil then
    1.14      return "NULL"
    1.15    else
    1.16 +    local mt = getmetatable(value)
    1.17 +    local converter = input_converters.mt
    1.18 +    if not converter then
    1.19 +      local t = type(value)
    1.20 +      if t == "table" and mt == nil then
    1.21 +        converter = input_converters.rawtable
    1.22 +      else
    1.23 +        converter = input.converters.t
    1.24 +      end
    1.25 +    end
    1.26      local converter =
    1.27        input_converters[getmetatable(value)] or
    1.28        input_converters[type(value)]

Impressum / About Us