<PackageReference Include="System.Text.Json" Version="9.0.5" />

GuidConverter

using System.Text.Json.Schema; namespace System.Text.Json.Serialization.Converters { internal sealed class GuidConverter : JsonPrimitiveConverter<Guid> { public override Guid Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { return reader.GetGuid(); } public override void Write(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options) { writer.WriteStringValue(value); } internal override Guid ReadAsPropertyNameCore(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { return reader.GetGuidNoValidation(); } internal override void WriteAsPropertyNameCore(Utf8JsonWriter writer, Guid value, JsonSerializerOptions options, bool isWritingExtensionDataProperty) { writer.WritePropertyName(value); } internal override JsonSchema GetSchema(JsonNumberHandling numberHandling) { return new JsonSchema { Type = JsonSchemaType.String, Format = "uuid" }; } } }