-Fixed error when deserializing nullable types with no content

-Changed JsonReaders to set TokenType to JsonToken.None after finishing content
-Changed the ReadAsXXX methods to return null instead of throwing an error when there is no content
This commit is contained in:
James Newton-King
2012-02-19 01:25:47 +13:00
parent c876e1d9cc
commit 4f8832adc0
11 changed files with 240 additions and 26 deletions
@@ -97,6 +97,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(JsonToken.EndObject, jsonReader.TokenType);
Assert.IsFalse(jsonReader.Read());
Assert.AreEqual(JsonToken.None, jsonReader.TokenType);
}
using (JsonReader jsonReader = new JTokenReader(o.Property("Test2")))
@@ -110,6 +111,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(new DateTimeOffset(2000, 10, 15, 5, 5, 5, new TimeSpan(11, 11, 0)), jsonReader.Value);
Assert.IsFalse(jsonReader.Read());
Assert.AreEqual(JsonToken.None, jsonReader.TokenType);
}
}
@@ -255,6 +257,9 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(0, lineInfo.LineNumber);
Assert.AreEqual(0, lineInfo.LinePosition);
Assert.AreEqual(false, lineInfo.HasLineInfo());
jsonReader.Read();
Assert.AreEqual(jsonReader.TokenType, JsonToken.None);
}
}
@@ -284,6 +289,7 @@ namespace Newtonsoft.Json.Tests.Linq
Assert.AreEqual(JsonToken.EndObject, jsonReader.TokenType);
Assert.IsFalse(jsonReader.Read());
Assert.AreEqual(JsonToken.None, jsonReader.TokenType);
}
}