将BSON转换为有效的JSON

BsonDocument.ToJson()方法返回无效的JSON,因为ObjectID()ISODate不是有效的JSON。

从仲裁BSON文档中获取有效JSON的最佳方法是什么?

你可以尝试这样的事情

 var document = new BsonDocument("_id", ObjectId.GenerateNewId()); var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; // key part Console.WriteLine(document.ToJson(jsonWriterSettings)); 

详细信息https://groups.google.com/forum/#!topic/mongodb-user/fQc9EvsPc4k