diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs index 845ed140..3c4aba94 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonReaderTests.cs @@ -95,7 +95,56 @@ namespace Newtonsoft.Json.Tests.Bson } [Test] - public void WriteValues() + public void ReadDouble() + { + byte[] data = MiscellaneousUtils.HexToBytes("10-00-00-00-01-30-00-8F-C2-F5-28-5C-FF-58-40-00"); + + MemoryStream ms = new MemoryStream(data); + BsonReader reader = new BsonReader(ms); + reader.ReadRootValueAsArray = true; + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.StartArray, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.Float, reader.TokenType); + Assert.AreEqual(99.99d, reader.Value); + Assert.AreEqual(typeof(double), reader.ValueType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.EndArray, reader.TokenType); + + Assert.IsFalse(reader.Read()); + Assert.AreEqual(JsonToken.None, reader.TokenType); + } + + [Test] + public void ReadDouble_Decimal() + { + byte[] data = MiscellaneousUtils.HexToBytes("10-00-00-00-01-30-00-8F-C2-F5-28-5C-FF-58-40-00"); + + MemoryStream ms = new MemoryStream(data); + BsonReader reader = new BsonReader(ms); + reader.FloatParseHandling = FloatParseHandling.Decimal; + reader.ReadRootValueAsArray = true; + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.StartArray, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.Float, reader.TokenType); + Assert.AreEqual(99.99m, reader.Value); + Assert.AreEqual(typeof(decimal), reader.ValueType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.EndArray, reader.TokenType); + + Assert.IsFalse(reader.Read()); + Assert.AreEqual(JsonToken.None, reader.TokenType); + } + + [Test] + public void ReadValues() { byte[] data = MiscellaneousUtils.HexToBytes("8C-00-00-00-12-30-00-FF-FF-FF-FF-FF-FF-FF-7F-12-31-00-FF-FF-FF-FF-FF-FF-FF-7F-10-32-00-FF-FF-FF-7F-10-33-00-FF-FF-FF-7F-10-34-00-FF-00-00-00-10-35-00-7F-00-00-00-02-36-00-02-00-00-00-61-00-01-37-00-00-00-00-00-00-00-F0-45-01-38-00-FF-FF-FF-FF-FF-FF-EF-7F-01-39-00-00-00-00-E0-FF-FF-EF-47-08-31-30-00-01-05-31-31-00-05-00-00-00-02-00-01-02-03-04-09-31-32-00-40-C5-E2-BA-E3-00-00-00-09-31-33-00-40-C5-E2-BA-E3-00-00-00-00"); MemoryStream ms = new MemoryStream(data); @@ -184,7 +233,6 @@ namespace Newtonsoft.Json.Tests.Bson Assert.AreEqual(JsonToken.None, reader.TokenType); } - [Test] public void ReadObjectBsonFromSite() { diff --git a/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs b/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs index 4752121a..67ecc15b 100644 --- a/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs +++ b/Src/Newtonsoft.Json.Tests/Bson/BsonWriterTests.cs @@ -114,6 +114,20 @@ namespace Newtonsoft.Json.Tests.Bson } #endif + [Test] + public void WriteDouble() + { + MemoryStream ms = new MemoryStream(); + BsonWriter writer = new BsonWriter(ms); + + writer.WriteStartArray(); + writer.WriteValue(99.99d); + writer.WriteEnd(); + + string bson = MiscellaneousUtils.BytesToHex(ms.ToArray()); + Assert.AreEqual("10-00-00-00-01-30-00-8F-C2-F5-28-5C-FF-58-40-00", bson); + } + [Test] public void WriteArrayBsonFromSite() { diff --git a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs index f0a72bd0..2140db10 100644 --- a/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs +++ b/Src/Newtonsoft.Json.Tests/JsonTextReaderTest.cs @@ -44,6 +44,57 @@ namespace Newtonsoft.Json.Tests [TestFixture] public class JsonTextReaderTest : TestFixtureBase { + [Test] + public void FloatParseHandling() + { + string json = "[1.0,1,9.9,1E-06]"; + + JsonTextReader reader = new JsonTextReader(new StringReader(json)); + reader.FloatParseHandling = Json.FloatParseHandling.Decimal; + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.StartArray, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(1.0d, reader.Value); + Assert.AreEqual(typeof(decimal), reader.ValueType); + Assert.AreEqual(JsonToken.Float, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(1, reader.Value); + Assert.AreEqual(typeof(long), reader.ValueType); + Assert.AreEqual(JsonToken.Integer, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(9.9d, reader.Value); + Assert.AreEqual(typeof(decimal), reader.ValueType); + Assert.AreEqual(JsonToken.Float, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(Convert.ToDecimal(1E-06), reader.Value); + Assert.AreEqual(typeof(decimal), reader.ValueType); + Assert.AreEqual(JsonToken.Float, reader.TokenType); + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.EndArray, reader.TokenType); + } + + [Test] + public void FloatParseHandling_NaN() + { + string json = "[NaN]"; + + JsonTextReader reader = new JsonTextReader(new StringReader(json)); + reader.FloatParseHandling = Json.FloatParseHandling.Decimal; + + Assert.IsTrue(reader.Read()); + Assert.AreEqual(JsonToken.StartArray, reader.TokenType); + + ExceptionAssert.Throws( + "Cannot read NaN as a decimal.", + () => reader.Read()); + } + [Test] public void UnescapeDoubleQuotes() { diff --git a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs index f0b57420..ff2a72c5 100644 --- a/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs +++ b/Src/Newtonsoft.Json.Tests/Linq/JValueTests.cs @@ -50,6 +50,19 @@ namespace Newtonsoft.Json.Tests.Linq [TestFixture] public class JValueTests : TestFixtureBase { + [Test] + public void FloatParseHandling() + { + JValue v = (JValue) JToken.ReadFrom( + new JsonTextReader(new StringReader("9.9")) + { + FloatParseHandling = Json.FloatParseHandling.Decimal + }); + + Assert.AreEqual(9.9d, v.Value); + Assert.AreEqual(typeof(decimal), v.Value.GetType()); + } + [Test] public void ChangeValue() { diff --git a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs index c1c106c2..f6c76867 100644 --- a/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json.Tests/Properties/AssemblyInfo.cs @@ -75,4 +75,4 @@ using System.Security; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("4.5.0.0")] -[assembly: AssemblyFileVersion("5.0.1.15924")] +[assembly: AssemblyFileVersion("5.0.1.15926")] diff --git a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs index 240c151e..b604d5f2 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/JsonSerializerTest.cs @@ -3908,6 +3908,21 @@ To fix this error either change the environment to be fully trusted, change the Assert.AreEqual(null, cc.Ignored); } + [Test] + public void DeserializeFloatAsDecimal() + { + string json = @"{'value':9.9}"; + + var dic = JsonConvert.DeserializeObject>( + json, new JsonSerializerSettings + { + FloatParseHandling = FloatParseHandling.Decimal + }); + + Assert.AreEqual(typeof(decimal), dic["value"].GetType()); + Assert.AreEqual(9.9d, dic["value"]); + } + [Test] public void ShouldSerializeTest() { @@ -6765,6 +6780,41 @@ Parameter name: value", } } + [Test] + public void SerializeFloatingPointHandling() + { + string json; + IList d = new List {1.1, double.NaN, double.PositiveInfinity}; + + json = JsonConvert.SerializeObject(d); + // [1.1,"NaN","Infinity"] + + json = JsonConvert.SerializeObject(d, new JsonSerializerSettings { FloatFormatHandling = FloatFormatHandling.Symbol }); + // [1.1,NaN,Infinity] + + json = JsonConvert.SerializeObject(d, new JsonSerializerSettings {FloatFormatHandling = FloatFormatHandling.DefaultValue}); + // [1.1,0.0,0.0] + + Assert.AreEqual("[1.1,0.0,0.0]", json); + } + +#if !(NET20 || NET35 || NET40 || PORTABLE || SILVERLIGHT) + [Test] + public void DeserializeReadOnlyListWithBigInteger() + { + string json = @"[ + 9000000000000000000000000000000000000000000000000 + ]"; + + var l = JsonConvert.DeserializeObject>(json); + + BigInteger nineQuindecillion = l[0]; + // 9000000000000000000000000000000000000000000000000 + + Assert.AreEqual(BigInteger.Parse("9000000000000000000000000000000000000000000000000"), nineQuindecillion); + } +#endif + [Test] public void SerializeCustomTupleWithSerializableAttribute() { @@ -7500,6 +7550,7 @@ Parameter name: value", }", json); } +#if !(PORTABLE || NET35 || NET20 || SILVERLIGHT) [Test] public void ReadTooLargeInteger() { @@ -7513,6 +7564,7 @@ Parameter name: value", "Error converting value 999999999999999999999999999999999999999999999999 to type 'System.Int64'. Path '[0]', line 1, position 49.", () => JsonConvert.DeserializeObject>(json)); } +#endif [Test] public void ReadStringFloatingPointSymbols() diff --git a/Src/Newtonsoft.Json/Bson/BsonReader.cs b/Src/Newtonsoft.Json/Bson/BsonReader.cs index 7e39c967..16207dbe 100644 --- a/Src/Newtonsoft.Json/Bson/BsonReader.cs +++ b/Src/Newtonsoft.Json/Bson/BsonReader.cs @@ -504,7 +504,12 @@ namespace Newtonsoft.Json.Bson switch (type) { case BsonType.Number: - SetToken(JsonToken.Float, ReadDouble()); + double d = ReadDouble(); + + if (_floatParseHandling == FloatParseHandling.Decimal) + SetToken(JsonToken.Float, Convert.ToDecimal(d, CultureInfo.InvariantCulture)); + else + SetToken(JsonToken.Float, d); break; case BsonType.String: case BsonType.Symbol: diff --git a/Src/Newtonsoft.Json/FloatFormatHandling.cs b/Src/Newtonsoft.Json/FloatFormatHandling.cs index 28fc0ddc..29959482 100644 --- a/Src/Newtonsoft.Json/FloatFormatHandling.cs +++ b/Src/Newtonsoft.Json/FloatFormatHandling.cs @@ -26,7 +26,7 @@ namespace Newtonsoft.Json { /// - /// Specifies float format handling options when writing special floating point values, e.g. , + /// Specifies float format handling options when writing special floating point numbers, e.g. , /// and with . /// public enum FloatFormatHandling diff --git a/Src/Newtonsoft.Json/FloatParseHandling.cs b/Src/Newtonsoft.Json/FloatParseHandling.cs new file mode 100644 index 00000000..72303745 --- /dev/null +++ b/Src/Newtonsoft.Json/FloatParseHandling.cs @@ -0,0 +1,42 @@ +#region License +// Copyright (c) 2007 James Newton-King +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +#endregion + +namespace Newtonsoft.Json +{ + /// + /// Specifies how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text. + /// + public enum FloatParseHandling + { + /// + /// Floating point numbers are parsed to . + /// + Double, + /// + /// Floating point numbers are parsed to . + /// + Decimal + } +} \ No newline at end of file diff --git a/Src/Newtonsoft.Json/JsonReader.cs b/Src/Newtonsoft.Json/JsonReader.cs index e10763cf..49bba741 100644 --- a/Src/Newtonsoft.Json/JsonReader.cs +++ b/Src/Newtonsoft.Json/JsonReader.cs @@ -112,6 +112,7 @@ namespace Newtonsoft.Json private int? _maxDepth; private bool _hasExceededMaxDepth; internal DateParseHandling _dateParseHandling; + internal FloatParseHandling _floatParseHandling; private readonly List _stack; /// @@ -160,6 +161,15 @@ namespace Newtonsoft.Json set { _dateParseHandling = value; } } + /// + /// Get or set how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text. + /// + public FloatParseHandling FloatParseHandling + { + get { return _floatParseHandling; } + set { _floatParseHandling = value; } + } + /// /// Gets or sets the maximum depth allowed when reading JSON. Reading past this depth will throw a . /// @@ -263,6 +273,7 @@ namespace Newtonsoft.Json _stack = new List(4); _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; + _floatParseHandling = FloatParseHandling.Double; CloseInput = true; } diff --git a/Src/Newtonsoft.Json/JsonSerializer.cs b/Src/Newtonsoft.Json/JsonSerializer.cs index c4f6f2bd..79bc7280 100644 --- a/Src/Newtonsoft.Json/JsonSerializer.cs +++ b/Src/Newtonsoft.Json/JsonSerializer.cs @@ -63,6 +63,7 @@ namespace Newtonsoft.Json private DateTimeZoneHandling? _dateTimeZoneHandling; private DateParseHandling? _dateParseHandling; private FloatFormatHandling? _floatFormatHandling; + private FloatParseHandling? _floatParseHandling; private StringEscapeHandling? _stringEscapeHandling; private CultureInfo _culture; private int? _maxDepth; @@ -347,9 +348,18 @@ namespace Newtonsoft.Json } /// - /// Get or set how special floating point values, e.g. , + /// Get or set how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text. + /// + public virtual FloatParseHandling FloatParseHandling + { + get { return _floatParseHandling ?? JsonSerializerSettings.DefaultFloatParseHandling; } + set { _floatParseHandling = value; } + } + + /// + /// Get or set how special floating point numbers, e.g. , /// and , - /// are written as JSON. + /// are written as JSON text. /// public virtual FloatFormatHandling FloatFormatHandling { @@ -476,6 +486,7 @@ namespace Newtonsoft.Json jsonSerializer._dateFormatString = settings._dateFormatString; jsonSerializer._dateFormatStringSet = settings._dateFormatStringSet; jsonSerializer._floatFormatHandling = settings._floatFormatHandling; + jsonSerializer._floatParseHandling = settings._floatParseHandling; jsonSerializer._stringEscapeHandling = settings._stringEscapeHandling; jsonSerializer._culture = settings._culture; jsonSerializer._maxDepth = settings._maxDepth; @@ -598,6 +609,13 @@ namespace Newtonsoft.Json reader.DateParseHandling = _dateParseHandling.Value; } + FloatParseHandling? previousFloatParseHandling = null; + if (_floatParseHandling != null && reader.FloatParseHandling != _floatParseHandling) + { + previousFloatParseHandling = reader.FloatParseHandling; + reader.FloatParseHandling = _floatParseHandling.Value; + } + int? previousMaxDepth = null; if (_maxDepthSet && reader.MaxDepth != _maxDepth) { @@ -615,6 +633,8 @@ namespace Newtonsoft.Json reader.DateTimeZoneHandling = previousDateTimeZoneHandling.Value; if (previousDateParseHandling != null) reader.DateParseHandling = previousDateParseHandling.Value; + if (previousFloatParseHandling != null) + reader.FloatParseHandling = previousFloatParseHandling.Value; if (_maxDepthSet) reader.MaxDepth = previousMaxDepth; diff --git a/Src/Newtonsoft.Json/JsonSerializerSettings.cs b/Src/Newtonsoft.Json/JsonSerializerSettings.cs index 991858ab..80307643 100644 --- a/Src/Newtonsoft.Json/JsonSerializerSettings.cs +++ b/Src/Newtonsoft.Json/JsonSerializerSettings.cs @@ -52,6 +52,7 @@ namespace Newtonsoft.Json internal const DateFormatHandling DefaultDateFormatHandling = DateFormatHandling.IsoDateFormat; internal const DateTimeZoneHandling DefaultDateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; internal const DateParseHandling DefaultDateParseHandling = DateParseHandling.DateTime; + internal const FloatParseHandling DefaultFloatParseHandling = FloatParseHandling.Double; internal const FloatFormatHandling DefaultFloatFormatHandling = FloatFormatHandling.String; internal const StringEscapeHandling DefaultStringEscapeHandling = StringEscapeHandling.Default; internal static readonly CultureInfo DefaultCulture; @@ -63,6 +64,7 @@ namespace Newtonsoft.Json internal DateTimeZoneHandling? _dateTimeZoneHandling; internal DateParseHandling? _dateParseHandling; internal FloatFormatHandling? _floatFormatHandling; + internal FloatParseHandling? _floatParseHandling; internal StringEscapeHandling? _stringEscapeHandling; internal CultureInfo _culture; internal bool? _checkAdditionalContent; @@ -234,7 +236,7 @@ namespace Newtonsoft.Json } /// - /// Get or set how special floating point values, e.g. , + /// Get or set how special floating point numbers, e.g. , /// and , /// are written as JSON. /// @@ -244,6 +246,15 @@ namespace Newtonsoft.Json set { _floatFormatHandling = value; } } + /// + /// Get or set how floating point numbers, e.g. 1.0 and 9.9, are parsed when reading JSON text. + /// + public FloatParseHandling FloatParseHandling + { + get { return _floatParseHandling ?? DefaultFloatParseHandling; } + set { _floatParseHandling = value; } + } + /// /// Get or set how strings are escaped when writing JSON text. /// diff --git a/Src/Newtonsoft.Json/JsonTextReader.cs b/Src/Newtonsoft.Json/JsonTextReader.cs index 6dc06b32..0aeb69ae 100644 --- a/Src/Newtonsoft.Json/JsonTextReader.cs +++ b/Src/Newtonsoft.Json/JsonTextReader.cs @@ -1243,7 +1243,11 @@ namespace Newtonsoft.Json // it's faster to do 3 indexof with single characters than an indexofany if (number.IndexOf('.') != -1 || number.IndexOf('E') != -1 || number.IndexOf('e') != -1) { - numberValue = Convert.ToDouble(number, CultureInfo.InvariantCulture); + if (_floatParseHandling == FloatParseHandling.Decimal) + numberValue = decimal.Parse(number, NumberStyles.Number | NumberStyles.AllowExponent, CultureInfo.InvariantCulture); + else + numberValue = Convert.ToDouble(number, CultureInfo.InvariantCulture); + numberType = JsonToken.Float; } else @@ -1452,6 +1456,9 @@ namespace Newtonsoft.Json { if (MatchValueWithTrailingSeperator(JsonConvert.NegativeInfinity)) { + if (_floatParseHandling == FloatParseHandling.Decimal) + throw new JsonReaderException("Cannot read -Infinity as a decimal."); + SetToken(JsonToken.Float, double.NegativeInfinity); } else @@ -1464,6 +1471,9 @@ namespace Newtonsoft.Json { if (MatchValueWithTrailingSeperator(JsonConvert.PositiveInfinity)) { + if (_floatParseHandling == FloatParseHandling.Decimal) + throw new JsonReaderException("Cannot read Infinity as a decimal."); + SetToken(JsonToken.Float, double.PositiveInfinity); } else @@ -1476,6 +1486,9 @@ namespace Newtonsoft.Json { if (MatchValueWithTrailingSeperator(JsonConvert.NaN)) { + if (_floatParseHandling == FloatParseHandling.Decimal) + throw new JsonReaderException("Cannot read NaN as a decimal."); + SetToken(JsonToken.Float, double.NaN); } else diff --git a/Src/Newtonsoft.Json/JsonWriter.cs b/Src/Newtonsoft.Json/JsonWriter.cs index 976db4c8..f27d6112 100644 --- a/Src/Newtonsoft.Json/JsonWriter.cs +++ b/Src/Newtonsoft.Json/JsonWriter.cs @@ -254,7 +254,7 @@ namespace Newtonsoft.Json } /// - /// Get or set how special floating point values, e.g. , + /// Get or set how special floating point numbers, e.g. , /// and , /// are written to JSON text. /// diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj index 3558d106..1e5b31f6 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Net20.csproj @@ -97,6 +97,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj index a878e53b..05d4c9b9 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Net35.csproj @@ -108,6 +108,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Net40.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Net40.csproj index b4e6e3a1..3d98fa84 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Net40.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Net40.csproj @@ -107,6 +107,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Portable.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Portable.csproj index 34fa3fc1..183a51d9 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Portable.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Portable.csproj @@ -74,6 +74,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj index dbfcf12e..16e1f22b 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.Silverlight.csproj @@ -109,6 +109,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.WinRT.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.WinRT.csproj index 43a344a3..92ccbd5a 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.WinRT.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.WinRT.csproj @@ -138,6 +138,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj index 2485b08d..d260d720 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.WindowsPhone.csproj @@ -80,6 +80,7 @@ + diff --git a/Src/Newtonsoft.Json/Newtonsoft.Json.csproj b/Src/Newtonsoft.Json/Newtonsoft.Json.csproj index efdcc44f..6ab40ad8 100644 --- a/Src/Newtonsoft.Json/Newtonsoft.Json.csproj +++ b/Src/Newtonsoft.Json/Newtonsoft.Json.csproj @@ -65,6 +65,7 @@ + diff --git a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs index 3a69dc19..01411f3c 100644 --- a/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs +++ b/Src/Newtonsoft.Json/Properties/AssemblyInfo.cs @@ -90,6 +90,6 @@ using System.Security; // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("4.5.0.0")] -[assembly: AssemblyFileVersion("5.0.1.15924")] +[assembly: AssemblyFileVersion("5.0.1.15926")] [assembly: CLSCompliant(true)] diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs index a74daa1f..66c2ef67 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerInternalReader.cs @@ -33,7 +33,9 @@ using System.Dynamic; #endif using System.Diagnostics; using System.Globalization; +#if !(PORTABLE || NET35 || NET20 || SILVERLIGHT) using System.Numerics; +#endif using System.Reflection; using System.Runtime.Serialization; using Newtonsoft.Json.Linq; @@ -665,8 +667,10 @@ To fix this error either change the JSON to a {1} or change the deserialized typ return Enum.ToObject(contract.NonNullableUnderlyingType, value); } +#if !(PORTABLE || NET35 || NET20 || SILVERLIGHT) if (value is BigInteger) return ConvertUtils.FromBigInteger((BigInteger)value, targetType); +#endif return Convert.ChangeType(value, contract.NonNullableUnderlyingType, culture); } diff --git a/Src/Newtonsoft.Json/Serialization/JsonSerializerProxy.cs b/Src/Newtonsoft.Json/Serialization/JsonSerializerProxy.cs index c616215c..6d1e1566 100644 --- a/Src/Newtonsoft.Json/Serialization/JsonSerializerProxy.cs +++ b/Src/Newtonsoft.Json/Serialization/JsonSerializerProxy.cs @@ -162,6 +162,12 @@ namespace Newtonsoft.Json.Serialization set { _serializer.FloatFormatHandling = value; } } + public override FloatParseHandling FloatParseHandling + { + get { return _serializer.FloatParseHandling; } + set { _serializer.FloatParseHandling = value; } + } + public override StringEscapeHandling StringEscapeHandling { get { return _serializer.StringEscapeHandling; }