-Numbers that contain e should be treated as doubles
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user