-Numbers that contain e should be treated as doubles

This commit is contained in:
JamesNK
2008-05-04 03:16:34 +00:00
parent d88e2cf2ca
commit 5f19fd9a7a
2 changed files with 14 additions and 1 deletions
@@ -37,6 +37,18 @@ namespace Newtonsoft.Json.Tests.Linq
{
public class LinqToJsonTest : TestFixtureBase
{
[Test]
public void DoubleValue()
{
JArray j = JArray.Parse("[-1E+4,100.0e-2]");
double value = (double)j[0];
Assert.AreEqual(-10000d, value);
value = (double)j[1];
Assert.AreEqual(1d, value);
}
[Test]
public void Manual()
{
+2 -1
View File
@@ -596,7 +596,8 @@ namespace Newtonsoft.Json
object numberValue;
JsonToken numberType;
if (number.IndexOf('.') == -1)
if (number.IndexOf(".", StringComparison.OrdinalIgnoreCase) == -1
&& number.IndexOf("e", StringComparison.OrdinalIgnoreCase) == -1)
{
numberValue = Convert.ToInt64(_buffer.ToString(), CultureInfo.InvariantCulture);
numberType = JsonToken.Integer;