2

Closed

IsoDateConverter converting string fields

description

From: https://github.com/MassTransit/MassTransit/pull/197

An ISO formatted date in a string field gets converted and repopulated with the culture. Following is a NUnit test checking for the desired behaviour.
    [TextFixture]
    public class IsoDateSerializationTest
    {
        [Test]
        public void Test()
        {
            JToken jtoken = JObject.Parse(@"{ IsoDate: ""1994-11-05T13:15:30Z"" }");
            Type deserializeType = typeof (MessageWithIsoDate);
            JsonSerializer serializer = new JsonSerializer();

            object obj;

            using (var jsonReader = new JTokenReader(jtoken))
            {
                obj = serializer.Deserialize(jsonReader, deserializeType);
            }

            MessageWithIsoDate msg = obj as MessageWithIsoDate;
            Assert.That(msg.IsoDate, Is.EqualTo("1994-11-05T13:15:30Z"));
        }
    }

    public class MessageWithIsoDate
    {
        public String IsoDate { get; set; }
    }
Closed Oct 3, 2013 at 11:19 AM by JamesNK

comments

legomaster wrote Aug 22, 2013 at 4:00 PM

Using JSON.NET 5.0.6.

rbosch_rgb wrote Sep 16, 2013 at 2:22 PM

+1