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

水深无声 2022-08-04 13:44 306阅读 0赞

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

public class TransPortCustomers

  1. \{
  2. public string orderNumberERP \{ get; set; \}
  3. public string customID \{ get; set; \}
  4. public string customName \{ get; set; \}
  5. public string customAddress \{ get; set; \}
  6. public string contactName \{ get; set; \}
  7. public string contactTel \{ get; set; \}
  8. public string coldflag \{ get; set; \}
  9. public Int32 caseqty \{ get; set; \}
  10. public Int32 bagqty \{ get; set; \}
  11. public string sendStatus \{ get; set; \}
  12. \}
  13. public class TransPortCustomersWithTransNO : TransPortCustomers
  14. \{
  15. internal string transNo \{ get; set; \}
  16. \}

发表评论

表情:
评论列表 (有 0 条评论,306人围观)

还没有评论,来说两句吧...

相关阅读

    相关 序列,反序列

    序列化: 对象的序列化主要有两种用途:   1) 把对象的字节序列永久地保存到硬盘上,通常存放在一个文件中;   2) 在网络上传送对象的字节序列。