[jOOQ/jOOQ#11165] Converter should use Jackson kotlin module if available when mapping JSON to kotlin data classes
This commit is contained in:
parent
59adfbf947
commit
7f883ccf0e
@ -213,7 +213,16 @@ final class Convert {
|
||||
try {
|
||||
Class<?> klass = Class.forName("com.fasterxml.jackson.databind.ObjectMapper");
|
||||
|
||||
jsonMapper = klass.getDeclaredConstructor().newInstance();
|
||||
try {
|
||||
Class<?> kotlin = Class.forName("com.fasterxml.jackson.module.kotlin.ExtensionsKt");
|
||||
jsonMapper = kotlin.getMethod("jacksonObjectMapper").invoke(kotlin);
|
||||
log.debug("Jackson kotlin module is available");
|
||||
}
|
||||
catch (Exception e) {
|
||||
jsonMapper = klass.getDeclaredConstructor().newInstance();
|
||||
log.debug("Jackson kotlin module is not available");
|
||||
}
|
||||
|
||||
jsonReadMethod = klass.getMethod("readValue", String.class, Class.class);
|
||||
jsonWriteMethod = klass.getMethod("writeValueAsString", Object.class);
|
||||
log.debug("Jackson is available");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user