i have a class A which has some private fields and the same class extends another class B which also has some private fields which are in class A.
public cla
I used GsonBuilder
and ExclusionStrategy
to avoid the redundant fields as below, it is simple and straight forward.
Gson json = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
if(f.getName().equals("netAmountPcy")){
return true;
}
return false;
}
@Override
public boolean shouldSkipClass(Class> clazz) {
return false;
}
}).create();