How to deserialize "MongoDB.Bson.ObjectId"

how to deserialization The object "MongoDB.Bson.ObjectId"

https://github.com/JamesNK/Newtonsoft.Json/issues/2378

I use [Newtonsoft.Json]

public class WebConfig
    {
  
        [MongoDB.Bson.Serialization.Attributes.BsonElement("_id")]
        public MongoDB.Bson.ObjectId MongoId { get; set; }
}

Newtonsoft.Json.JsonSerializationException:
“Error converting value “5f3facb172225d2400eed3f9” to type ‘MongoDB.Bson.ObjectId’. Path ‘MongoId’.”

pls help me

I have try it

MongoDB.Bson.Serialization.BsonSerializer.Deserialize<T>(Newtonsoft.Json.JsonConvert.SerializeObject(JObject));

But i failed…

Thanks

This worked wonderfully for me. I found a completed version of a class with the same name here

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.