I am having a class like following,
public class Student { public int id; public String name; public int age; }
Now I want to c
JsonObject jsObj = (JsonObject) new Gson().toJsonTree(stu2); jsObj.remove("age"); // remove field 'age' jsObj.addProperty("key", "value"); // add field 'key' System.out.println(jsObj);
You can manipulate with JsonObject