using System.Text.Json;
using System.Text.Json.Serialization;

public sealed class ObservationSourceJsonConverter : JsonConverter<ObservationSource>
{
    public override ObservationSource Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        => DbStringEnumJson.Read(ref reader, ObservationSourceExtensions.FromDbString);

    public override void Write(Utf8JsonWriter writer, ObservationSource value, JsonSerializerOptions options)
        => writer.WriteStringValue(value.ToDbString());
}
