2 / 2
Mar 11

Before updating the library, my application used to store data in MongoDB like this: ‘field’: {‘$numberDecimal’: ‘1.00000000’}. After the update, it’s storing data like this: ‘field’: ‘1.00000000’. I would like to know how to modify it so that I can deserialize the object both in the old and new formats. A large volume of data has already been stored in the new format, but there is still a much larger amount of data stored in the old format. I am using BsonMapper to deserialize MongoDB fields. It works correctly when the data is in the new format, but it breaks when it’s in the old format.

In the same application, I’m mapping to retrieve data from the database. The decimal field is mapped as follows:

cm.MapMember(p => p.Field1).SetElementName("field1").SetSerializer(new DecimalSerializer(BsonType.Decimal128));

When I receive data in the old format, the application breaks.

11 months later

After updating the MongoDB library, deserialization differences often arise due to changes in driver behavior, BSON parsing, or data type handling. It’s best to check the release notes for breaking changes and update your schema mappings accordingly. If you’re using frameworks, ensure compatibility with the latest driver version. Also, tools like Tele Latino can help streamline content access, but for MongoDB, debugging logs and type validation are key to resolving deserialization issues.