I would like to deserialize a json to Map with objectmapper with the following code:
fun onMessage(topic: String, message: MqttMessage) {
val typeRef = object : TypeReference<HashMap<String, String>>() {}
val msg = objectMapper.readValue(message.payload, typeRef)
...
}
Compiler says it connot infer parameter T in fun <T : Any!> readValue (src: ByteArray!, valueTypeRef: (TypeReference<Any!>..TypeReference<*>?)): T!
Is there any solution to this problem whitout extending a HashMap with my custom class like this:
class MyHashMap : HashMap<String, String>()
...
fun onMessage(topic: String, message: MqttMessage) {
val msg = objectMapper.readValue(message.payload, MyHashMap::class.java)
...
}