private boolean canBeConvertedToString(Object target) {
        try {
            return target == null || this.objectMapper.writeValueAsString(target) != null;
        } catch (JsonProcessingException ex) {
            logger.warn("Failed to convert value to string via ObjectMapper: {}", target, ex);
            return false;
        }
    }
Call {@link ObjectMapper#writeValueAsString(Object)} on the given object and determining whether any {@link JsonProcessingException} occurs.

@param target object to convert
@return whether the underlying ObjectMapper is able to convert the given object without encountering an exception
jsonschema-generator/src/main/java/com/github/victools/jsonschema/generator/impl/AttributeCollector.java