Skip to content
Browse files

JSON serialization using IsoDateFormat

  • Loading branch information...
1 parent e1b27a6 commit 66c8b8d99860d493bdf54f467746770ca30a64fe Alberto Monteiro committed Jul 29, 2012
View
5 Restfulie.Server.Tests/Marshalling/Serializers/Json/JsonSerializerTests.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System;
using NUnit.Framework;
using Restfulie.Server.Marshalling.Serializers;
using Restfulie.Server.Marshalling.Serializers.Json;
@@ -20,12 +20,13 @@ public void SetUp()
[Test]
public void ShouldSerializeAsResource()
{
- var resource = new SomeResource {Amount = 123.45, Name = "John Doe"};
+ var resource = new SomeResource {Amount = 123.45, Name = "John Doe", UpdatedAt = new DateTime(2012,7,29)};
var json = serializer.Serialize(resource);
Assert.That(json.Contains("\"Name\":\"John Doe\""));
Assert.That(json.Contains("\"Amount\":123.45"));
+ Assert.That(json.Contains("\"UpdatedAt\":\"2012-07-29T00:00:00\""));
}
[Test]
View
2 Restfulie.Server/Marshalling/Serializers/Json/JsonSerializer.cs
@@ -16,7 +16,7 @@ public string Serialize(object resource)
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
- jsonSerializer.Converters.Add(new JavaScriptDateTimeConverter());
+ jsonSerializer.Converters.Add(new IsoDateTimeConverter());
jsonSerializer.Serialize(textWriter, resource);
return textWriter.ToString();

0 comments on commit 66c8b8d

Please sign in to comment.
Something went wrong with that request. Please try again.