Unity crashes when I tried the TinyJson from Nakama

I wanted to test if the json result is correct or not so I made a simple script in the Start method like this

            Message m = new Message()
            {
                message = "Hay",
                invitationUrl = "https://www.jembut.com/",
                time = DateTime.Now
            };
            var input = new Dictionary<string, Message>() { { "test", m } }.ToJson();
            var output = input.FromJson<Dictionary<string, Message>>()["test"];
            Debug.Log($"Output test: {output.message} | {output.invitationUrl} | {output.time.ToString()}");

but then Unity crashes lol. Is it only intended for deserializing from the Content message?

Edit: tried in a fresh project and it caused stack overflow :face_with_diagonal_mouth:


I guess it only accept string message only? :sweat_smile:

Damn man, the support is so slow till I finally can figure it out. If you guys stumbled upon the same case like me, don’t use the TinyJson from nakama. Simply because it sucks at serializing. Just use Newtonsoft.Json will do. And you finally can pass as many variables as you want in the nakama panel


You will likely to struggle so much if you are new to this and learning a Pirate Panic project is not enough!

@aliakbarm534 we’ve used TinyJson in production without issue, it’s likely you’re doing something wrong with how you’re declaring your Message class or how you’re annotating the properties to be serialized.

Best.

1 Like

you’re right and I already figured it out yesterday

I’m glad you’ve resolved your issue.

Kindly report your solution as it may help other members of the community going through the same struggles :).

Best

when you want to serialize the json make sure you only send string key:string value. but you can deserialize it as a class that contains some variable that has similar variable name like this
public MyClass { string key; }