I am trying to cast a child type to a parent type. The thing is since the child class extends parent class, when casting to the parent type child specific attributes are also kept. I would like to leave out some of the child class attributes and keep only parent class attributes.
I have found a way of doing this with GSON nevertheless, I would like to know if it is possible to do so with plain JAVA code.
Trick with GSON
JsonUtils.getGsonBuilder().fromJson(JsonUtils.getGsonBuilder().toJson(respondents.get(0),RespondentBase.class),RespondentBase.class);