Json serialization order modification

Json serialization order modification

As shown below, the serialization order can be modified by using the JsonProperty feature. The default order is -1, and the smaller the value, the higher the front.

 	[System.Serializable]
    public class DriverProperties_Base
    {
    
    
        /// <summary>
        /// 设备id
        /// </summary>
        [JsonProperty(Order = -4)]
        public string Id="";

        /// <summary>
        /// 类型
        /// </summary>
        [JsonProperty(Order = -3)]
        public string driver="";

        /// <summary>
        /// 层级
        /// </summary>
        [JsonProperty(Order =-2)]
        public string hierarchy="";
    }

Guess you like

Origin blog.csdn.net/qq_26318597/article/details/131247423