Skip to content

Commit 9beca8a

Browse files
committed
Changed encode_number() number->string conversion method
Using Lua5.3, tonumber() will represent the float `1` as "1.0" instead of "1". Using string.format("%14g, x) `1` is converted to "1" regardless of whether it's an int or float. All other conversions seem to be uneffected.
1 parent 7b8aef0 commit 9beca8a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

json.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ local function encode_number(val)
8383
if val ~= val or val <= -math.huge or val >= math.huge then
8484
error("unexpected number value '" .. tostring(val) .. "'")
8585
end
86-
return tostring(val)
86+
return string.format("%.14g", val)
8787
end
8888

8989

0 commit comments

Comments
 (0)