将 Transient 修改器添加到现有对象

Adding Transient modifier to existing object

我有一个对象定义为

class MyObj {
        int a;
        String b;
        Date d;   //I will add the transient 
}

在序列化期间对象没有 'transient' 并且序列化的字符串包含日期。现在我在日期中添加 'transient' 修饰符。它能反序列化吗?

我已经用我的机器进行了测试,它可以正常工作,但不知何故我对这台机器没有信心。我正在为 serialize/deserialize.

使用 Gson

没有!

也就是 definition of transient keyword in java

引用

transient is a Java keyword which marks a member variable not to be serialized when it is persisted to streams of bytes.transient is a Java keyword which marks a member variable not to be serialized when it is persisted to streams of bytes.