How to get the java class from a class name?


#1

I am trying to deserialize a Json string into an object using Jackson with Kotlin.

I need to construct a type object like so:

val mapper : ObjectMapper = ObjectMapper();
val type : JavaType = mapper.getTypeFactory()
         .constructParametricType(..,, ...);
val result : OperationResult<String> = mapper.readValue(
                  responseString, type);

I’ve tried the following but they do not work.

val type : JavaType = mapper.getTypeFactory()
            .constructParametricType(
             javaClass<OperationResult>, 
             javaClass<String>); // Unresolved javaClass<T>

val type : JavaType = mapper.getTypeFactory()
            .constructParametricType(
             OperationResult::class, 
             String::class);

How do I get a java class from the type names?


#2

Please see answer on StackOverflow.