Ban*_*San 10 .net c# mongodb bson mongodb-.net-driver
该BsonDocument.ToJson()方法返回无效的JSON,因为ObjectID()它ISODate是无效的JSON.
从仲裁BSON文档获取有效JSON的最佳方法是什么?
Mai*_*nul 11
你可以尝试这样的事情
var document = new BsonDocument("_id", ObjectId.GenerateNewId());
var jsonWriterSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.Strict }; // key part
Console.WriteLine(document.ToJson(jsonWriterSettings));
Run Code Online (Sandbox Code Playgroud)
详细信息 https://groups.google.com/forum/#!topic/mongodb-user/fQc9EvsPc4k