I\'m trying to learn Gson and I\'m struggling with field exclusion. Here are my classes
public class Student { private Long id; privat
You can explore the json tree with gson.
Try something like this :
gson.toJsonTree(student).getAsJsonObject() .get("country").getAsJsonObject().remove("name");
You can add some properties also :
gson.toJsonTree(student).getAsJsonObject().addProperty("isGoodStudent", false);
Tested with gson 2.2.4.