Nakama.TinyJson Parsing High Numbers Problem

Hi, I am trying to send data from Nakma server using Lua like this

local test_data =
[‘ThisIsNumber’] = 1577999999,
[‘ThisIsString’] = “Hello World”,
[‘ThisIsUnixTime’] = nk.time()

dispatcher.broadcast_message(120, nk.json_encode(test_data))

The problem is that when I receive the data on unity the values will be like this
1577999999 —> 1577800000
and nk.time() —> will not be correct

When I received the data on Socket.OnMatchState
I did like this

string string_data_json = System.Text.Encoding.UTF8.GetString(matchState.State);
TestDataClass = tdc = JsonParser.FromJson(string_data_json);

Note 1 --> I printed the string_data_json and the data were correct, the problem is with JsonParser.FromJson.

Note 2 --> In my TestDataClass
ThisIsNumber is Int
ThisIsUnixTime is float
ThisIsString is string

@Mohammed Please can you open an issue on the TinyJson repo with the details of the valid which loses precision when you decode it on the .NET/Unity side.

In the meantime a good workaround where you need to guarantee this precision is to just send the value as a string and parse it on the client-side into a long value.

1 Like

Done. I opened an issue.