WIn_RustTools/DataList/CommunityList.cs

126 lines
2.4 KiB
C#
Raw Normal View History

2024-12-06 01:26:57 +00:00
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;
2024-12-06 01:26:57 +00:00
} = 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;
}
2024-12-06 01:26:57 +00:00
[JsonConverter(typeof(BoolStringConverter))] // 使用自定义转换器
public bool Enable
{
get; set;
}
[JsonProperty("dynamicColor")]
public string DynamicColor
{
get; set;
}
}
2024-12-06 01:26:57 +00:00
public class BoolStringConverter : JsonConverter<bool>
{
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");
}
}
}