1

I am using the solution in the follow SO post (Deserializing dates with dd/mm/yyyy format using Json.Net), but am getting the following error when trying to Deserialize MyObject:

String was not recognized as a valid DateTime.

Any help would be appreciated.

class Program
{
    static void Main(string[] args)
    {
        var json = "{\"data\":[{\"courseID\":43547,\"endDate\":\"01/01/2014\"},{\"courseID\":40949,\"endDate\":\"10/04/2013\"},{\"courseID\":40439,\"endDate\":\"7/03/2013\"}]}";

        var myCheckedCourses = JsonConvert.DeserializeObject<MyObject>(json, 
            new IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" });

    }
}

class MyObject
{
    public List<Object2> data { get; set; }
}

[JsonObject]
public class Object2
{
    public int CourseID { get; set; }
    public Nullable<System.DateTime> EndDate { get; set; }
}
Community
  • 1
  • 1
ADH
  • 2,971
  • 6
  • 34
  • 53

1 Answers1

1

The date format needed to be changed to d/MM/yyyy.

ADH
  • 2,971
  • 6
  • 34
  • 53