From e1abe1c45c168838494b702a53a88aa8b7fc348c Mon Sep 17 00:00:00 2001 From: niki Date: Fri, 11 Jan 2019 19:12:00 +0100 Subject: [PATCH 1/2] fix array detection when using overloaded indexing --- json.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json.lua b/json.lua index a3d7530..0c0ff80 100644 --- a/json.lua +++ b/json.lua @@ -65,7 +65,7 @@ local function encode_table(val, stack) stack[val] = true - if val[1] ~= nil or next(val) == nil then + if rawget(val[1]) ~= nil or next(val) == nil then -- Treat as array -- check keys are valid and it is not sparse local n = 0 for k in pairs(val) do From d3f417d4d493243fcd9417ab1c580eb8802470d4 Mon Sep 17 00:00:00 2001 From: niki Date: Fri, 11 Jan 2019 19:12:00 +0100 Subject: [PATCH 2/2] fix array detection when using overloaded indexing --- json.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json.lua b/json.lua index a3d7530..01edb8e 100644 --- a/json.lua +++ b/json.lua @@ -65,7 +65,7 @@ local function encode_table(val, stack) stack[val] = true - if val[1] ~= nil or next(val) == nil then + if rawget(val, 1) ~= nil or next(val) == nil then -- Treat as array -- check keys are valid and it is not sparse local n = 0 for k in pairs(val) do