Here is a similar issue, but it didn't get any answers. How to format a list of dates using JsonConverter attribute
Here is the question:
I try to use a JsonConverter attribute using a custom IsoDateTimeConverter on the DateTime fields that need to be formatted as ISO date time format
public class DateConverter : IsoDateTimeConverter
{
public DateConverter()
{
DateTimeFormat = "yyyy-MM-dd";
}
}
public class A
{
[JsonConverter(typeof(DateConverter))]
public List<DateTime> Example { get; set; }
}
This results in the following error:
Unexpected value when converting date. Expected DateTime or DateTimeOffset, got System.Collections.Generic.List`1[System.DateTime].
I checked all the documents from https://www.newtonsoft.com, but I can't find anything relate to this issue.
Please give me some ideas about that. Thanks