i'm trying to make a generic json-mapper plugin: ...
# announcements
t
i'm trying to make a generic json-mapper plugin:
Copy code
@FunctionalInterface
interface JsonToObjectMapper {
    fun <T> map(json: String, targetClass: Class<T>): T
}

var jsonToObjectMapper = object : JsonToObjectMapper { // use lambda here somehow?
    override fun <T> map(json: String, targetClass: Class<T>): T {
    }
}
according to this SO post (https://stackoverflow.com/questions/22588518/lambda-expression-and-generic-method/22588738#22588738) you can't combine generics and lambdas in java, but is it possible to achieve in kotlin somehow?
c
var jsonToObjectMapper =	JsonToObjectMapper<String> { json, _ -> json }
t
@Czar that doesn't do work, and also i don't want to create a mapper for a specific type, the implementation should also be generic
c
Works for me :) as for generic type, yeah, there is no such thing as generic lambda, I believe