Convert String into MongoDB BsonDocument

If you have a long string in JSON format, and you want to convert it into a BSONDocument for insertion into a MongoDB database.You can simply do it by defining the query as

string json = "{ 'foo' : 'bar' }";  
BsonDocument document = BsonDocument.Parse(json);

My Name is Dileep Singh, Noder, Javascript Lover & NoSql Developer, Fitness Freak, Love to travel new places, learning photography & Music Manic ♯ ♩ ♬

Posted in MongoDB, Snippets