-Improved default null and value handing when JSON value is not compatible with property value

-Added interfaces, structs and enums as valid targets of JsonConverterAttribute
This commit is contained in:
JamesNK
2010-05-27 08:37:34 +00:00
parent fc6c041196
commit f5ed7be283
7 changed files with 59 additions and 4 deletions
@@ -35,6 +35,20 @@ namespace Newtonsoft.Json.Tests.Serialization
{
public class NullValueHandlingTests : TestFixtureBase
{
[Test]
public void DeserializeNullIntoDateTime()
{
DateTimeTestClass c = JsonConvert.DeserializeObject<DateTimeTestClass>(@"{DateTimeField:null}", new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Assert.AreEqual(c.DateTimeField, default(DateTime));
}
[Test]
public void DeserializeEmptyStringIntoDateTimeWithEmptyStringDefaultValue()
{
DateTimeTestClass c = JsonConvert.DeserializeObject<DateTimeTestClass>(@"{DateTimeField:""""}", new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Assert.AreEqual(c.DateTimeField, default(DateTime));
}
[Test]
public void NullValueHandlingSerialization()
{