Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3562

BsonDocument.Parse failure on large double

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Gone away
    • Icon: Major - P3 Major - P3
    • None
    • 2.12.2
    • None
    • None

    Description

      BsonDocument.Parse("{ \"val\": -99999996802856924650656260769173209088 }");
      

      'BsonDocument.Parse("{ \"val\": -99999996802856924650656260769173209088 }")' threw an exception of type 'System.OverflowException'
          Data: {System.Collections.ListDictionaryInternal}
          HResult: -2146233066
          HelpLink: null
          InnerException: null
          Message: "Value was either too large or too small for an Int64."
          Source: "mscorlib"
          StackTrace: "   at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)\r\n   at MongoDB.Bson.IO.JsonScanner.GetNumberToken(JsonBuffer buffer, Int32 firstChar)\r\n   at MongoDB.Bson.IO.JsonScanner.GetNextToken(JsonBuffer buffer)\r\n   at MongoDB.Bson.IO.JsonReader.PopToken()\r\n   at MongoDB.Bson.IO.JsonReader.ReadBsonType()\r\n   at MongoDB.Bson.Serialization.Serializers.BsonDocumentSerializer.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)\r\n   at MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)\r\n   at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize[TValue](IBsonSerializer`1 serializer, BsonDeserializationContext context)\r\n   at MongoDB.Bson.BsonDocument.Parse(String json)"
          TargetSite: {Int64 ParseInt64(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo)}
      

      Note that the same JSON string will parse using JObject.Parse:

      Newtonsoft.Json.Linq.JObject.Parse("{ \"val\": -99999996802856924650656260769173209088 }");
      

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: