1
我想將Json對象轉換爲MongoDb BsonDocument,但是在將從Json對象賦值的轉換日期轉換爲字符串而不是日期之後。以下示例將BsonValueType作爲字符串輸出。
有什麼方法可以正確轉換爲Bson日期值嗎?當轉換Json到Bson Document無法正確地轉換日期值
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
非常感謝。有效!! –