Skip to content

Commit

Permalink
Improved error message when encoding mixed/bad key types
Browse files Browse the repository at this point in the history
  • Loading branch information
rxi committed Sep 5, 2015
1 parent 4fb28bb commit 19b61e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 19b61e0

Please sign in to comment.