I have model like this
public class testModel {
public boolean a = true;
public Test2 test2 = new Test2();
public class Test2 {
public boolean b = true;
}
}
and a json like this
{
"test2":{}
}
when i parse this json with Gson
testModel testModel = new Gson().fromJson("{ \"test2\":{}}", testModel.class);
Log.e("test", testModel.a + " " + testModel.test2.b);
and the log is:
E/test: true false
testModel.a is 'true' but testmodel.test2.b is 'false' why Gson changed the default value of b while b is not exist in json? what is the difference between b and a?
is it a Gson bug?