I need help understanding how to use the the JsonConverter.ReadJson method to convert a value of any number of types (string, boolean, Date, int, array, object) to a specific custom type.
For example, I have the following;
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
//where reader.Value could be a string, boolean, Date, int, array, object
//and in this example the value of reader.Value is a string
return new MyCustomType(reader.Value);
}
But this gives error;
Compilation error (line 115, col 36): Argument 1: cannot convert from 'object' to 'string'
I'm a bit green with C#, just need help making this work.