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

JsonReader fails with BsonInternalException when trying to deserialize Decimal128

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 2.19.1
    • Affects Version/s: None
    • Component/s: Serialization
    • None
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      dynamic doc = BsonSerializer.Deserialize<object>("{ Amount: NumberDecimal('42.42') }");
      Console.WriteLine(doc.Amount);
      

      Stack Trace:

      Unhandled exception. MongoDB.Bson.BsonInternalException: Invalid BsonType.
         at MongoDB.Bson.IO.JsonReader.SkipValue() in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/IO/JsonReader.cs:line 869
         at MongoDB.Bson.IO.IBsonReaderExtensions.FindElement(IBsonReader reader, String name) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/IO/IBsonReaderExtensions.cs:line 40
         at MongoDB.Bson.Serialization.Conventions.ObjectDiscriminatorConvention.GetActualType(IBsonReader bsonReader, Type nominalType) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/Serialization/Conventions/ObjectDiscriminatorConvention.cs:line 119
         at MongoDB.Bson.Serialization.Serializers.ObjectSerializer.DeserializeDiscriminatedValue(BsonDeserializationContext context, BsonDeserializationArgs args) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/Serialization/Serializers/ObjectSerializer.cs:line 349
         at MongoDB.Bson.Serialization.Serializers.ObjectSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/Serialization/Serializers/ObjectSerializer.cs:line 193
         at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize[TValue](IBsonSerializer`1 serializer, BsonDeserializationContext context) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/Serialization/IBsonSerializerExtensions.cs:line 49
         at MongoDB.Bson.Serialization.BsonSerializer.Deserialize[TNominalType](IBsonReader bsonReader, Action`1 configurator) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/Serialization/BsonSerializer.cs:line 118
         at MongoDB.Bson.Serialization.BsonSerializer.Deserialize[TNominalType](String json, Action`1 configurator) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/src/MongoDB.Bson/Serialization/BsonSerializer.cs:line 163
         at Program.<Main>$(String[] args) in /Users/james/Dropbox/code/mongodb/mongo-csharp-driver/tests/MongoDB.Driver.TestConsoleApplication/Program.cs:line 9
      

            Assignee:
            james.kovacs@mongodb.com James Kovacs
            Reporter:
            james.kovacs@mongodb.com James Kovacs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: