Class ObjectIdConverter
A custom converter to handle serialization and deserialization of ObjectId values
public class ObjectIdConverter : JsonConverter<ObjectId>
- Inheritance
-
JsonConverter<ObjectId>ObjectIdConverter
- Inherited Members
Methods
Read(ref Utf8JsonReader, Type, JsonSerializerOptions)
Reads and converts JSON to an MongoDB.Bson.ObjectId value.
public override ObjectId Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
Parameters
readerUtf8JsonReadertypeToConvertTypeoptionsJsonSerializerOptions
Returns
- ObjectId
Write(Utf8JsonWriter, ObjectId, JsonSerializerOptions)
Writes an MongoDB.Bson.ObjectId value as a JSON object with a $objectId property.
public override void Write(Utf8JsonWriter writer, ObjectId value, JsonSerializerOptions options)
Parameters
writerUtf8JsonWritervalueObjectIdoptionsJsonSerializerOptions