dave08
02/07/2018, 4:06 PMinline fun <reified T: PaymentResponse> T.toJson() = ServerResponse.Json(this)
Given:
sealed class ServerResponse {
data class Error(val statusCode: Int, val message: String) : ServerResponse()
data class Json(val jsonObj: Any) : ServerResponse() {
val jsonString: String
get() = Klaxon().toJsonString(jsonObj)
}
}
Or do I have to worry about type erasure @cedric?