code: public String buildPretty() throws IOException {
      try {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(this);
      } catch (IOException ex) {
        throw ex;
      }
    }
docs: Create a string represenation of the Mail object JSON and pretty print it.
  @return a pretty JSON string.
  @throws IOException in case of a JSON marshal error.