code: private String asJSON(Object entity) {
  
          String entityJson = null;
  
          try {
              entityJson = this.mapper.writeValueAsString(entity);
          } catch (Exception e) {
              LOG.error("Could not parse as JSON: " + e.getMessage());
          }
  
          return entityJson;
      }
docs: Convert an object to json.