• util.TableToJSON Bug
    4 replies, posted
[code]local Test = { Value = 1229174882 } PrintTable(Test) local JSON = util.TableToJSON( Test ) print(JSON) local Table = util.JSONToTable( JSON ) PrintTable(Table)[/code] The value goes from 1229174882 to 1229170048. Fixed by using a string instead of an integer. None the less its broken.
Thank you, I appreciate you taking the time to do that ^^ Confirmation makes me feel like I know what I'm doing xD (not to mention that's kind of a major issue, could have a beginner stumped for weeks as you assume the functions provided to you work(which is a huge flaw in anyone's logic))
I don't know if these two issues are directly related, I could see in the background a table being converted to a string via util.TableToJSON and sent to the client via string then converted back to a table with util.JSONToTable, but either way here is the same issue with an integer of 1229174882 being converted to 1229174912 [code]local TestTable = { TestInt = 1229174882 } PrintTable(TestTable) util.AddNetworkString( "TestMsg" ) net.Start( "TestMsg" ) net.WriteTable( TestTable ) net.Broadcast()[/code] This will print 1229174882 [code] net.Receive( "TestMsg", function(len) local TestTable = net.ReadTable() PrintTable(TestTable) end )[/code] When it is received via the client the table's value has been increased to 1229174912 It cannot be a limit to integer size due to the fact that the value goes up. This is highly problematic especially when your using large integer keys in a table (such as having player UniqueID's as the table key. Of course you could convert to a string then convert back to an integer although strings take up more data and the increased overhead, while negligible, is still an increased overhead by using tonumber() and tostring()
Sorry, you need to Log In to post a reply to this thread.