次のコードは「null」を返します。
package test;
import com.google.gson.Gson;
class test {
public static void main(String[] args) {
class BagOfPrimitives {
private int value1 = 1;
private String value2 = "abc";
private transient int value3 = 3;
BagOfPrimitives() {
// no-args constructor
}
}
BagOfPrimitives obj = new BagOfPrimitives();
System.out.println(obj.value1 + obj.value2 + obj.value3);
Gson gson = new Gson();
System.out.println(gson.toJson(obj));
}
}