Convert string into MongoDB BsonDocument

后端 未结 3 943
误落风尘
误落风尘 2020-12-02 15:37

I have a long string in JSON format, and I want to convert it into a BSONDocument for insertion into a MongoDB database. How do I do the conversion? I\'m using the officia

3条回答
  •  温柔的废话
    2020-12-02 16:00

    Using Version 2.1 of MongoDB's .NET library

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

提交回复
热议问题