We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dbf4b2d commit 2885270Copy full SHA for 2885270
json.lua
@@ -108,7 +108,12 @@ local function encode_number(val)
108
if val ~= val or val <= -math.huge or val >= math.huge then
109
error("unexpected number value '" .. tostring(val) .. "'")
110
end
111
- return string.format("%.14g", val)
+ -- Handle integer values separately to avoid floating-point conversion
112
+ if math.type(val) == "integer" then
113
+ return string.format("%d", val) -- Format as an integer
114
+ else
115
+ -- Use 20 significant digits for non-integer numbers
116
+ return string.format("%.20g", val)
117
118
119
0 commit comments