Forum Discussion

DefinitivVair0's avatar
DefinitivVair0
Copper Contributor
Jan 05, 2025

C# JSON deserialization returns null

Hi there,

so first of, I just started working with JSON deserialization today and just know the bare basics.

 

Basically I am currently developing a bot wich should get data from an API of a minecraft server.

So far everything works perfectly except one thing: Since a minecraft uuid can start with a number (like for example "121e2d73913041ffaa49af39d124673f") visual studio automatically creates the uuid part with "_" ("public _121E2d73913041ffaa49af39d124673f _121e2d73913041ffaa49af39d124673f { get; set; }").

Now, when I try to request data from a uuid wich starts with a letter everything works fine. However when I request it from a uuid with a number, it will return null.

My guess is, that since the JSON itself does not have "_", it wont get deserialized into the in-code version with "_".

-> btw, I am using System.Text.Json, not Newtonsoft.Json but would have no problems changing... I hope.

 

So, my question is, if there is a way to get this to work or maby work arround it?

 

Thanks in advance :D

No RepliesBe the first to reply

Resources