I'm developing a program that deserializes JSON data into a list of a custom class and then uploads it all to my SQL Server.
string json = streamReader.ReadToEnd();
JObject jsonEntriesRaw = JsonConvert.DeserializeObject( json ) as JObject;
JArray jsonEntries = jsonEntriesRaw[ "events" ] as JArray; //since the data i actually need is wrapped in "events"
List<MoveUpdateEntry> entries = jsonEntries.ToObject<List<MoveUpdateEntry>>(); //error occurs here
My custom class...
public class MoveUpdateEntry
{
public DateTime errorCreateDate { get; set; }
}
...has a (Sql?)DateTime field that I have no clue how to properly parse data into.
The issue I'm facing is that the program doesn't understand how to work with the specific date format I'm dealing with (yyyyMMdd hh:mm:ss).
Unhandled Exception: Newtonsoft.Json.JsonReaderException: Could not convert string to DateTime: 20200630 18:19:01. Path 'events[0].errorCreateDate'.
How can I make the JsonReader
know what type of formatting to expect?