Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion json.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ local function encode_number(val)
if val ~= val or val <= -math.huge or val >= math.huge then
error("unexpected number value '" .. tostring(val) .. "'")
end
return string.format("%.14g", val)
local intVal = math.tointeger(val)
if intVal == val then
return string.format("%d", intVal)
else
return string.format("%.14g", val)
end
end


Expand Down