BsonSerializationException raised if element name ends in period

I am writing a C # application that reads from an XML file, converts it to JSON, and loads it into MongoDB. Some of our tags are structured with a period at the end, for example:

<BatteryTest.>GOOD</BatteryTest.>

Using the Newtonsoft library, I can easily convert XML to JSON. When I go to deserialize it into a BsonDocument, I have problems:

var document = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(jsonText);

The following error message appears:

An exception like "MongoDB.Bson.BsonSerializationException" occurred in mscorlib.dll but was not handled in the user code

Additional Information: The element name is 'BatteryTest.' not valid.

, , , . XML, , .

JSON? , MongoDB, ?

+2
1

MongoDB , . JSON, BSONDocument.

+1

Source: https://habr.com/ru/post/1621971/


All Articles