using System.Text.Json;
using System.Text.Json.Serialization;
using XF.Domain.Constants;

namespace DataSharing.Province;

public class ProvinceJsonSerializerOptions
{
    private static readonly Lazy<JsonSerializerOptions> LazyUnStandardDatetimeJsonConverter =
        new(() =>
        {
            var options = JsonDefaults.DefaultJsonSerializerOptions;
            options.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
            options.Converters.Add(new UnStandardDatetimeJsonConverter());
            return options;
        });

    private ProvinceJsonSerializerOptions() { }

    public static JsonSerializerOptions UnStandardDatetimeJsonOptions =>
        LazyUnStandardDatetimeJsonConverter.Value;
}