public static String toJSONString(final Object obj) {
        try {
            return mapper.writeValueAsString(obj);
        } catch (final JsonProcessingException e) {
            logger.error("Cannot to JSON string", e);
        }
        return null;
    }
public static String toJSONString ( final Object obj ) { try { return mapper . writeValueAsString ( obj ) ; } catch ( final JsonProcessingException e ) { logger . error ( "Cannot to JSON string" , e ) ; } return null ; }
Returns the JSON string for the object.

@param obj the object
@return the JSON string