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
pac4j-oauth/src/main/java/org/pac4j/oauth/profile/JsonHelper.java