From 19b61e0628b492fef6a126a501cd63f6cfeb166f Mon Sep 17 00:00:00 2001 From: rxi Date: Sat, 5 Sep 2015 19:56:53 +0100 Subject: [PATCH] Improved error message when encoding mixed/bad key types --- json.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/json.lua b/json.lua index 7ca5452..7df19c7 100644 --- a/json.lua +++ b/json.lua @@ -55,7 +55,7 @@ local function encode_table(val, stack) local n = 0 for k in pairs(val) do if type(k) ~= "number" then - error("invalid table: mixed key types") + error("invalid table: mixed or invalid key types") end n = n + 1 end @@ -73,7 +73,7 @@ local function encode_table(val, stack) -- Treat as an object for k, v in pairs(val) do if type(k) ~= "string" then - error("invalid table: mixed key types") + error("invalid table: mixed or invalid key types") end table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) end