Convert MongoDB BsonDocument into a string

Journeyman picture Journeyman · May 9, 2011 · Viewed 18.8k times · Source

How do a convert an entire MongoDB BsonDocument into a string?

(I'm using the official C# driver)

Answer

AndrewC picture AndrewC · May 9, 2011

You can convert BsonDocument into a JSON formatted string using MongoDB.Bson.BsonExtensionMethods.ToJson.