I pull in some JSON, deserialize it to a POJO, edit some properties of the object, and now I want to serialize it back to JSON with GSON and send it back.
How do i
Pojo myPojo = new Pojo(); Gson gson = new Gson(); gson.toJson(myPojo);
The gson.toJson() returns a String, not a JsonObject.
If you want to get a real JsonObject better do this:
JsonObject json = (JsonObject)parser.parse(new Gson().toJson(myPojo));