我有一个JSON格式的长字符串,我想把它转换成BSONDocument,插入MongoDB数据库.我该如何转换?我用的是官方的C#driver.
我有一个JSON格式的长字符串,我想把它转换成BSONDocument,插入MongoDB数据库.我该如何转换?我用的是官方的C#driver.
答案是:
string json = "{ 'foo' : 'bar' }";
MongoDB.Bson.BsonDocument document
= MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonDocument>(json);