zoukankan      html  css  js  c++  java
  • enum & json 之间的转换

    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;
    

      

  • 相关阅读:

    入门动态规划问题
    AC自动机
    KMP算法
    [OpenGL]用鼠标拖拽图形移动
    HDU-2222 Keywords Search
    Trie
    Manacher算法
    linux环境搭建
    Android Studio使用JNI和NDK进行开发
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/10709272.html
Copyright © 2011-2022 走看看