java序列化

http://developer.51cto.com/art/201202/317181.htm

static变量也不会被序列化

 

transient关键字

当某个字段被声明为transient后,默认序列化机制就会忽略该字段。此处将Person类中的age字段声明为transient,如下所示

  1. public class Person implements Serializable {  
  2.     ...  
  3.     transient private Integer age = null;  
  4.     ...  

再执行SimpleSerial应用程序,会有如下输出:

  1. arg constructor  
  2. [John, null, MALE] 

可见,age字段未被序列化。

FastJSON、Gson和Jackson性能对比

原文地址:https://www.cnblogs.com/lnas01/p/5266058.html