I have the following class:
public class Configuration
{
public Color ErrorColor { get; set; }
// other things
}
The Color
struct is defined in a library I am using:
public struct Color
{
public Color(uint rawValue) { /* ... */ }
// other things
}
If I attempt to desterilize the following data:
{
"ErrorColor": 16711680
}
With the following code:
var config = JsonConvert.DeserializeObject<Configuration>(data);
This exception gets thrown:
Newtonsoft.Json.JsonSerializationException: 'Error converting value 16711680 to type 'Discord.Color'.
How can I get Newtonsoft to call the constructor of this type when deserializing? I know you can make custom JsonConverter
's, but I only need it for one property, not all of them.