I am trying to create custom json converter ,which can parse date using specified formats
public class MultiFormatDateConverter: JsonConverter {
public override bool CanWrite => true;
public override bool CanConvert(Type objectType) {
return objectType == typeof (DateTime);
}
private readonly string[] _formats;
public MultiFormatDateConverter(params string[] formats) {
_formats = formats;
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) {
....
}
}
this is how I am trying to use it
public class MyClass{
[JsonConverter(typeof(MultiFormatDateConverter),"dd/MM/yyyy","dd/MM/yy")]
public DateTime Date{get;set;}
}
Getting error
Newtonsoft.Json.JsonException : Error creating 'MultiFormatDateConverter'. ----> Newtonsoft.Json.JsonException : No matching parameterized constructor found for 'MultiFormatDateConverter'.
What am I missing?