Serialize a POJO to JSON with GSON
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:
JSONParser parser = new JSONParser();
JsonObject json = (JsonObject)parser.parse(new Gson().toJson(myPojo));