Function json.generate is using string.format("%g", obj) to convert numbers to strings. This has an undesired effect of mangling longer integers as follows:
obj = {session=1684119503}
json.make_object(obj)
str = json.generate(obj)
String str is now {"session": 1.68412e+009}.
I wonder if it would be more appropriate to use tostring(obj), which does not have this side-effect.
Digging into the history, the "%g" conversion has been there since the initial json.lua commit by David in 2010 (r16896).
Function
json.generateis usingstring.format("%g", obj)to convert numbers to strings. This has an undesired effect of mangling longer integers as follows:String
stris now{"session": 1.68412e+009}.I wonder if it would be more appropriate to use
tostring(obj), which does not have this side-effect.Digging into the history, the "%g" conversion has been there since the initial
json.luacommit by David in 2010 (r16896).