Permalink
Browse files

Merge branch 'master' of https://github.com/codedemonuk/ServiceStack.…

…Text into codedemonuk-master

Conflicts:
	tests/ServiceStack.Text.Tests/JsonTests/BasicJsonTests.cs
  • Loading branch information...
2 parents 4b71a45 + 3794a00 commit 4fc9e978a7dcec9a54ac7c5090a4d57c02d30a17 @mythz mythz committed Feb 28, 2012
@@ -107,8 +107,10 @@ public void WriteDateTime(TextWriter writer, object oDateTime)
public void WriteNullableDateTime(TextWriter writer, object dateTime)
{
- if (dateTime == null) return;
- WriteDateTime(writer, dateTime);
+ if (dateTime == null)
+ writer.Write( JsonUtils.Null );
+ else
+ WriteDateTime(writer, dateTime);
}
public void WriteGuid(TextWriter writer, object oValue)
@@ -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.Reset();
- 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);
}
}
@@ -182,4 +187,4 @@ public void Can_override_name()
Assert.That(JsonSerializer.SerializeToString(person), Is.EqualTo("{\"MyID\":123,\"Name\":\"Abc\"}"));
}
}
-}
+}

0 comments on commit 4fc9e97

Please sign in to comment.