-Added additional ToString overloads to JValue

-Fixed poor error message when dynamic type cannot be created during deserialization
-Fixed error when setting a null value on a dynamic type during deserialization
-Fixed JsonTextReader.ReadAsDecimal not attempting to convert string values to decimal
This commit is contained in:
JamesNK
2011-02-24 10:14:08 +00:00
parent 1824aa4b59
commit 71446e9772
8 changed files with 169 additions and 11 deletions
@@ -28,6 +28,7 @@ using System.Collections.Generic;
#if !SILVERLIGHT && !PocketPC && !NET20
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Web.Script.Serialization;
#endif
using System.Text;
@@ -4178,5 +4179,29 @@ keyword such as type of business.""
""Name"": null
}", json);
}
public class DeserializeStringConvert
{
public string Name { get; set; }
public int Age { get; set; }
public double Height { get; set; }
public decimal Price { get; set; }
}
[Test]
public void DeserializeStringEnglish()
{
string json = @"{
'Name': 'James Hughes',
'Age': '40',
'Height': '44.4',
'Price': '4'
}";
DeserializeStringConvert p = JsonConvert.DeserializeObject<DeserializeStringConvert>(json);
Assert.AreEqual(40, p.Age);
Assert.AreEqual(44.4, p.Height);
Assert.AreEqual(4d, p.Price);
}
}
}