Custom Newtonsoft JSON deserialization

I have a dictionary where: - The key will always be a string - The value will be either: - string - an object of MyClass Normally, you would do something like:
c#
string jsonData = ""; // Some data...
Dictionary<string, object> data = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonData);
c#
string jsonData = ""; // Some data...
Dictionary<string, object> data = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonData);
However, this wont deserialize the non-string value into an instance of MyClass like it normally would. How can tell the deserializer how to deserialize a string vs an object?
4 Replies
UnemployedNinja
UnemployedNinjaOP10mo ago
I figured it out. I have to use a JSON converter
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
UnemployedNinja
UnemployedNinjaOP10mo ago
A couple reasons. Just readability and a small amount of compression. And also just because I'm awkward
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server