Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Show Nullable<DateTime> json serialization bug.

  • Loading branch information...
commit e6b61b846163ec317a3eb1985c153ab6c26272c3 1 parent 8b078aa
@codedemonuk codedemonuk authored
Showing with 8 additions and 3 deletions.
  1. +8 −3 tests/ServiceStack.Text.Tests/JsonTests/BasicJsonTests.cs
View
11 tests/ServiceStack.Text.Tests/JsonTests/BasicJsonTests.cs
@@ -79,7 +79,8 @@ public void Serialize_skips_null_values_by_default()
Name = "Brandon",
Type = "Programmer",
SampleKey = 12,
- Nothing = (string)null
+ Nothing = (string)null,
+ NullableDateTime = null
};
var s = JsonSerializer.SerializeToString(o);
@@ -94,13 +95,14 @@ public void Serialize_can_include_null_values()
Name = "Brandon",
Type = "Programmer",
SampleKey = 12,
- Nothing = null
+ Nothing = null,
+ NullableDateTime = null
};
JsConfig.IncludeNullValues = true;
var s = JsonSerializer.SerializeToString(o);
JsConfig.IncludeNullValues = false;
- Assert.That(s, Is.EqualTo("{\"Name\":\"Brandon\",\"Type\":\"Programmer\",\"SampleKey\":12,\"Nothing\":null}"));
+ Assert.That(s, Is.EqualTo("{\"Name\":\"Brandon\",\"Type\":\"Programmer\",\"SampleKey\":12,\"Nothing\":null,\"NullableDateTime\":null}"));
}
[Test]
@@ -151,12 +153,15 @@ public string Nothing
set;
}
+ public DateTime? NullableDateTime { get; set; }
+
public NullValueTester()
{
Name = "Miguel";
Type = "User";
SampleKey = 1;
Nothing = "zilch";
+ NullableDateTime = new DateTime(2012, 01, 01);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.