using System.Diagnostics.CodeAnalysis; using Newtonsoft.Json; public class CommunityList { [JsonProperty("code")] public int Code { get; set; } [JsonProperty("message")] public string Message { get; set; } [JsonProperty("data")] public Data[] data { get; set; } public class Data { [JsonProperty("account")] public string Account { get; set; } [JsonProperty("cover")] public string Cover { get; set; } [JsonProperty("introduce")] public string Introduce { get; set; } [JsonProperty("fans")] public string Fans { get; set; } [JsonProperty("follower")] public string Follower { get; set; } [JsonProperty("praise")] public string Praise { get; set; } [JsonProperty("userName")] public string UserName { get; set; } [JsonProperty("headIcon")] public string HeadIcon { get; set; } = string.Empty; [JsonProperty("email")] public string Email { get; set; } [JsonProperty("permission")] public string Permission { get; set; } [JsonProperty("loginTime")] public string LoginTime { get; set; } [JsonProperty("gender")] public string Gender { get; set; } [JsonConverter(typeof(BoolStringConverter))] // 使用自定义转换器 public bool Enable { get; set; } [JsonProperty("dynamicColor")] public string DynamicColor { get; set; } } public class BoolStringConverter : JsonConverter { public override bool ReadJson(JsonReader reader, Type objectType, [AllowNull] bool existingValue, bool hasExistingValue, JsonSerializer serializer) { var value = reader.Value.ToString(); return value.ToLower() == "true"; } // 重写 WriteJson 方法 public override void WriteJson(JsonWriter writer, bool value, JsonSerializer serializer) { writer.WriteValue(value ? "true" : "false"); } } }