-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
|
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]
|
[Test]
|
||||||
public void Manual()
|
public void Manual()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -596,7 +596,8 @@ namespace Newtonsoft.Json
|
|||||||
object numberValue;
|
object numberValue;
|
||||||
JsonToken numberType;
|
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);
|
numberValue = Convert.ToInt64(_buffer.ToString(), CultureInfo.InvariantCulture);
|
||||||
numberType = JsonToken.Integer;
|
numberType = JsonToken.Integer;
|
||||||
|
|||||||
Reference in New Issue
Block a user