public static <T> String toJson(T object) {
    Validate.notNull(object, "null input object");
    StringWriter out = new StringWriter();
    try {
      MAPPER.writeValue(out, object);
    } catch (IOException e) {
      String errorMessage = "Failed to serialize object: " + object;
      LOG.error(errorMessage, e);
      throw new SamzaException(errorMessage, e);
    }
    return out.toString();
  }
Serialize a Java object into JSON string.
@param object object to be serialized
@param <T> type of the input object
@return JSON string
samza-sql/src/main/java/org/apache/samza/sql/util/JsonUtil.java