Code
·
15 lines
·
461 bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using System.Text.Json.Serialization;
using System.Text.Json;
namespace BsonExtensions.Converters;
public class GuidBsonConverter : JsonConverter<Guid>
{
public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
throw new NotImplementedException();
}
public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) =>
writer.WriteRawValue($"UUID(\"{value}\")", true);
}