❔ Newtonsoft.JSON Nested Json deserialized incorrectly

I'm serializing and transmitting the following class
[JsonObject(MemberSerialization.OptIn)]
public class Message
{
[JsonProperty]
public Types Type { get; }

[JsonProperty]
public string Json { get; }
}
[JsonObject(MemberSerialization.OptIn)]
public class Message
{
[JsonProperty]
public Types Type { get; }

[JsonProperty]
public string Json { get; }
}
The Json property contains a serialized object of relevance to the Type e.g.: If Type is DoMove, the Json is expected to be a serialized point. Serializing this works fine and the nested json is escaped properly, but deserializing just skips the json. It works with the Type, but just doesn't touch the nested json. First and foremost, I'm looking for a workaround to this, alternatively I'm looking for suggestions to improve this entire system... because it sucks.
2 Replies
Aurumaker72
Aurumaker72OP2y ago
Apparently, storing an object works and Newtonsoft.JSON seems to provide functionailty for deserializing that too Yeah this system sucks and I couldn't find any good resources on .NET + message-based networking
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server