• JSON integer limit?
    4 replies, posted
So I'm trying to store an integer of 'os.time' with JSON, but this is what I get: [code]1360172930 1 = 1360169984[/code] That was generated by this code: [code]local temp = { os.time() } local str = util.TableToJSON( temp ) print( os.time() ) PrintTable( util.JSONToTable( str ) )[/code] You can see there's a pretty huge difference in the 2 numbers. It's to be stored in a MySQL database together with some other stuff, and this is what I got in the db: '1.36017e+09'. Is there any way to overcome this? because I need to accurately store the time, and if I did something like substract 1.3billion or however much it is, it'd still start getting inaccurate within a few months.
They are right, the problem is how long it takes to encode and decode the JSON. JSON can store 32 bit integers which have a limit of 2147483648 for a signed value which JSON uses. Lua uses doubles for numbers so they also have to be converted.
I just noticed this wasn't in the LUA section, shit. Can anyone move this, please?
tostring the number
Already did, but thanks. :)
Sorry, you need to Log In to post a reply to this thread.