jsonconvert序列化时避免序列化子类

来源:互联网 发布:路由器mac地址怎么设置 编辑:程序博客网 时间:2024/05/27 01:49

类如下。在序列化时,尽管指定的是父类序列化。但实际会序列化掉子类。只需要把子类的字段定义为internal就可以了。

public class TransPortCustomers

    {
        public string orderNumberERP { get; set; }
        public string customID { get; set; }
        public string customName { get; set; }
        public string customAddress { get; set; }
        public string contactName { get; set; }
        public string contactTel { get; set; }
        public string coldflag { get; set; }
        public Int32 caseqty { get; set; }
        public Int32 bagqty { get; set; }
        public string sendStatus { get; set; }
    }
    public class TransPortCustomersWithTransNO : TransPortCustomers
    {
       internal string transNo { get; set; }
    }
0 0
原创粉丝点击