【发布时间】:2017-05-09 10:07:56
【问题描述】:
我正在尝试将 Json 对象转换为 MongoDb BsonDocument,但是在转换后从 Json 对象值的日期转换为字符串而不是日期。以下示例将 BsonValueType 输出为字符串。
有什么方法可以正确转换为 Bson Date 值?
var newObject = new JObject {
{ "name", "John" },
{ "age", 25 },
{ "registeredDate" , "2017-05-09T09:14:06+00:00"},
};
BsonDocument bsonObj = BsonDocument.Parse(newObject.ToString());
Console.WriteLine(bsonObj["registeredDate"].BsonType);
//Outputs String
【问题讨论】:
标签: json.net mongodb-.net-driver