-Fixed flag enum items not being correctly camel cased

-Fixed JsonValidatingReader not validating the first array item twice
-Fixed JsonSchema not correctly validating integers as a subset of decimal
-Changed JsonTextReader.Culture to be CultureInfo.InvariantCulture by default
This commit is contained in:
JamesNK
2011-11-18 09:36:01 +00:00
parent da7e4508d7
commit 5831b11de1
8 changed files with 240 additions and 9 deletions
@@ -5045,6 +5045,38 @@ keyword such as type of business.""
Assert.AreEqual(new byte[] { 72, 63, 62, 71, 92, 55 }, newObject.Data);
}
}
[Test]
public void DeserializeDecimalsWithCulture()
{
CultureInfo initialCulture = Thread.CurrentThread.CurrentCulture;
try
{
CultureInfo testCulture = CultureInfo.CreateSpecificCulture("nb-NO");
Thread.CurrentThread.CurrentCulture = testCulture;
Thread.CurrentThread.CurrentUICulture = testCulture;
string json = @"{ 'Quantity': '1.5', 'OptionalQuantity': '2.2' }";
DecimalTestClass c = JsonConvert.DeserializeObject<DecimalTestClass>(json);
Assert.AreEqual(1.5m, c.Quantity);
Assert.AreEqual(2.2d, c.OptionalQuantity);
}
finally
{
Thread.CurrentThread.CurrentCulture = initialCulture;
Thread.CurrentThread.CurrentUICulture = initialCulture;
}
}
}
public class DecimalTestClass
{
public decimal Quantity { get; set; }
public double OptionalQuantity { get; set; }
}
public class TestObject