< p >
BsonDocument.ToJson()
方法返回的 JSON 无效,因为 ObjectID()
和 ISODate
不是有效的 JSON。
从任意 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
"Property" : NumberDecimal("23.44")
, 而是"Property" : { "$numberDecimal": "23.44"}
。这能不能像普通人一样直接将小数值放入结果中呢?我只想要"Property" : 23.44
。 - Piotr Kula