diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Converters/System.Text.Json/Boolean/TextualBooleanConverter.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Converters/System.Text.Json/Boolean/TextualBooleanConverter.cs deleted file mode 100644 index 84b68a26..00000000 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Converters/System.Text.Json/Boolean/TextualBooleanConverter.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Serialization; - -namespace System.Text.Json.Converters -{ - internal class TextualBooleanConverter : JsonConverter - { - private readonly JsonConverter _converter = new TextualNullableBooleanConverter(); - - public override bool Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - return _converter.Read(ref reader, typeToConvert, options) ?? default; - } - - public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) - { - _converter.Write(writer, value, options); - } - } -} diff --git a/src/SKIT.FlurlHttpClient.Wechat.Api/Converters/System.Text.Json/Boolean/TextualNullableBooleanConverter.cs b/src/SKIT.FlurlHttpClient.Wechat.Api/Converters/System.Text.Json/Boolean/TextualNullableBooleanConverter.cs deleted file mode 100644 index bd6598ba..00000000 --- a/src/SKIT.FlurlHttpClient.Wechat.Api/Converters/System.Text.Json/Boolean/TextualNullableBooleanConverter.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System.Text.Json.Serialization; - -namespace System.Text.Json.Converters -{ - internal class TextualNullableBooleanConverter : JsonConverter - { - public override bool? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - if (reader.TokenType == JsonTokenType.Null) - { - return null; - } - else if (reader.TokenType == JsonTokenType.True) - { - return true; - } - else if (reader.TokenType == JsonTokenType.False) - { - return false; - } - else if (reader.TokenType == JsonTokenType.String) - { - string? value = reader.GetString(); - if (value == null) - return null; - - if ("true".Equals(value, StringComparison.OrdinalIgnoreCase)) - return true; - else if ("false".Equals(value, StringComparison.OrdinalIgnoreCase)) - return false; - } - - throw new JsonException(); - } - - public override void Write(Utf8JsonWriter writer, bool? value, JsonSerializerOptions options) - { - if (value.HasValue) - writer.WriteStringValue(value.Value ? "true" : "false"); - else - writer.WriteNullValue(); - } - } -}