enum 转为 string:EnumMember & StringEnumConverter
public enum CampaignStatus : Int32
{
[EnumMember(Value = "Running")]
Running = 1,
[EnumMember(Value = "Archived")]
Archived = 2,
[EnumMember(Value = "NotRunning")]
NotRunning = 3
}
/// <summary>
/// optional
/// </summary>
[JsonProperty("campaignStatus")]
[JsonConverter(typeof(StringEnumConverter))]
public CampaignStatus? CampaignStatus { get; set; }
enum array 转为string array:StringEnumConverter & JsonProperty
[JsonProperty(PropertyName = "Status", ItemConverterType = typeof(StringEnumConverter))]
public CampaignStatus[] Status { get; set; }
dll引用:
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;