top of page
outismiglamar

Cannot Deserialize Bsondocument From Bsontype Array: Learn from the Experts on Stack Overflow



When i run this code I am able to see some data, but I'v got exception"Cannot deserialize string from BsonType Int32."I think that one of property is represented in database as int , but I dont know how to deal with it ? How come one property in one entity is int and the same property in another object is string ?What I have to do to read all database ?


Most of the time, people use Json as a serialization format to transfer data between applications. MongoDB has built-in serializers to convert from Json to Bson. The problem is that the resulting Bson will not handle the intended DateTime string to be a BsonType.DateTime, but instead it will be handled as a BsonType.String. I want to give you an option on how to build something, that properly deserializes Json string values (that are of a given DateTime format) to BsonDateTime values.




Cannot Deserialize Bsondocument From Bsontype Array




c# - Cannot deserialize a 'BsonDocument from BsonType 'Array' - Stack Overflow. Attempting to run the following code:var doc = BsonDocument.Parse(rawjson);where rawjson is:["PersonName":"Jim Test"]Returns the following error:Cannot deserialize a 'BsonDocument' from. Stack Overflow.


2. The second way would be use an extension that knows how to deserialize the BSON properly. I see there's a newer component on the forge that might work. -overview/7548/bsontoolkt-xif. Alternatively you could create your own extension to expose an action that will convert BSON to JSON using C#. This stack overflow article has some ideas on how to convert BSON to JSON: -mongodb-bsondocument-to-valid-json-in-c-sharp


Serializer and Deserializer, which are used in bson::(tofrom)_(bsondocument), have never implemented the is_human_readable requirement from their respective serde traits, meaning they default to true. The raw serializer and deserializer, which are used in bson::to_vec and bson::from_slice, do report as non-human readable though. The unfortunate result of this inconsistency is that types that change their serialized format depending on whether the (de)serializer is human readable or not may produce different BSON depending on whether to_bson or to_vec are used. To help address this issue, this release includes support for configuring Serializer and Deserializer to report themselves as not human readable.


2ff7e9595c


1 view0 comments

Recent Posts

See All

Comments


bottom of page