-Added support for MS format JSON dates to ReadAsDateTime

-Fixed parsing certain JSON with comments into a JObject
-Tests
This commit is contained in:
James Newton-King
2014-03-01 18:31:01 +13:00
parent 0f77cd1b03
commit b43afdcc0a
12 changed files with 328 additions and 57 deletions
@@ -407,6 +407,7 @@ namespace Newtonsoft.Json.Tests.Serialization
string json = "{}";
List<string> errors = new List<string>();
JsonSerializer serializer = new JsonSerializer();
serializer.SpecialPropertyHandling = SpecialPropertyHandling.Default;
serializer.Error += delegate(object sender, ErrorEventArgs args)
{
errors.Add(args.ErrorContext.Path + " - " + args.ErrorContext.Member + " - " + args.ErrorContext.Error.Message);
@@ -539,6 +540,7 @@ namespace Newtonsoft.Json.Tests.Serialization
"{'badarray':[0,x,2],'goodarray':[0,1,2]}",
new JsonSerializerSettings
{
SpecialPropertyHandling = SpecialPropertyHandling.Default,
Error = (sender, arg) =>
{
errors.Add(arg.ErrorContext.Error.Message);
@@ -565,7 +567,11 @@ namespace Newtonsoft.Json.Tests.Serialization
const int maxDepth = 256;
using (var jsonTextReader = new JsonTextReader(new StringReader(input)) { MaxDepth = maxDepth })
{
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { MaxDepth = maxDepth });
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings
{
MaxDepth = maxDepth,
SpecialPropertyHandling = SpecialPropertyHandling.Default
});
jsonSerializer.Error += (sender, e) =>
{
errors.Add(e.ErrorContext.Error.Message);
@@ -595,7 +601,7 @@ namespace Newtonsoft.Json.Tests.Serialization
const int maxDepth = 256;
using (var jsonTextReader = new JsonTextReader(new StringReader(input)) { MaxDepth = maxDepth })
{
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { MaxDepth = maxDepth });
JsonSerializer jsonSerializer = JsonSerializer.Create(new JsonSerializerSettings { MaxDepth = maxDepth, SpecialPropertyHandling = SpecialPropertyHandling.Default });
jsonSerializer.Error += (sender, e) =>
{
errors.Add(e.ErrorContext.Error.Message);
@@ -634,7 +640,8 @@ namespace Newtonsoft.Json.Tests.Serialization
{
errors.Add(e.ErrorContext.Error.Message);
e.ErrorContext.Handled = true;
}
},
SpecialPropertyHandling = SpecialPropertyHandling.Default
});
Assert.AreEqual(true, newDynamicObject.Explicit);