using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Client.Infrastructure.Parsers.Converters { public class BooleanConverter : JsonConverter { public override bool CanConvert(Type objectType) { return objectType == typeof(bool); } public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { var value = reader.Value; if (value == null) { return null; } return value?.ToString()?.Trim('0') != ""; } public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { writer.WriteRawValue(value == null ? null : (string)value); } } }