美文网首页
C#实体类属性大写转JSON变成小写

C#实体类属性大写转JSON变成小写

作者: a9b854aded01 | 来源:发表于2017-12-28 14:06 被阅读0次

    C#服务实体类序列化后属性名称开头如果有大写使用JAVA 反序列化工具时无法对应实体类小写字母,需要把序列化里面属性开头字母转换为小写字母;
    使用Newtonsoft中的[JosonProperty]标签

     public class StockStorageInfo
        {
            /// <summary>
            /// 产品名称
            /// </summary>
            [DataMember]
            [JsonProperty("productname")]
            public string ProductName { get; set; }
            /// <summary>
            /// 产品描述
            /// </summary>
            [DataMember]
            [JsonProperty("productdescription")]
            public string ProductDescription { get; set; }
            /// <summary>
            /// 库存状态
            /// </summary>
            [DataMember]
            [JsonProperty("subjectname")]
            public string SubjectName { get; set; }
            /// <summary>
            /// 货位描述
            /// </summary>
            [DataMember]
            [JsonProperty("galdescription")]
            public string GalDescription { get; set; }
            /// <summary>
            /// 重量
            /// </summary>
            [DataMember]
            [JsonProperty("an")]
            public decimal? AN { get; set; }
            /// <summary>
            /// 件数
            /// </summary>
            [DataMember]
            [JsonProperty("pn")]
            public int? PN { get; set; }
            /// <summary>
            /// 件数
            /// </summary>
            [DataMember]
            [JsonProperty("rarname")]
            public string RarName { get; set; }
    
    
        }
    

    {"d":"{"Result":[{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test11","an":172.0000,"pn":46,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test11","an":182.0000,"pn":56,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"冻结","galdescription":"test11","an":6.0000,"pn":5,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"冻结","galdescription":"test11","an":6.0000,"pn":5,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test6","an":3.0000,"pn":3,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test11","an":14.0000,"pn":14,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test2","an":1.0000,"pn":1,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test2","an":1.0000,"pn":1,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test2","an":1.0000,"pn":1,"rarname":"test11"},{"productname":"产品1","productdescription":"塑化产品2/规格2/产品等级2/塑化产地2/包装222","subjectname":"可用库存","galdescription":"test2","an":1.0000,"pn":1,"rarname":"test11"}],"ErrorStatus":6,"FeedbackMessage":"1,5,41"}"}

    相关文章

      网友评论

          本文标题:C#实体类属性大写转JSON变成小写

          本文链接:https://www.haomeiwen.com/subject/iwtvgxtx.html