I have this test case that fails. Does anyone know how to fix this?
[TestMethod]
public void Should_deserialize_utc_datestring_to_utc_date_with_AlwaysUseUtc_true()
{
string dateString = "2014-06-02T21:00:00.0000000Z";
DateTime dateRaw = new DateTime(2014, 6, 2, 21, 0, 0, 0, DateTimeKind.Utc);
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
settings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
DateTime dateSerialized = JsonConvert.DeserializeObject<DateTime>(dateString, settings);
dateSerialized.Should().Be(dateRaw);
}
The error I get (using ReSharper as my TestRunner):
Testing Method When_json_serializing_dates.Should_deserialize_utc_datestring_to_utc_date_with_AlwaysUseUtc_true exception: Newtonsoft.Json.JsonReaderException: Unexpected character encountered during parsing: T. Path '', line 1, position 10.
source
share