Robert Jaros
10/04/2020, 12:12 PM@JsonTypeInfo
from jackson in the common source of MPP project? I have tried to create expected annotation like this:
expect annotation class JsonTypeInfo(val use: Id, val property: String) {
enum class Id {
CLASS
}
}
but actual typealias JsonTypeInfo = com.fasterxml.jackson.annotation.JsonTypeInfo
doesn't compile (fails with the Id enum class)Robert Jaros
10/04/2020, 4:43 PMexpect enum class Id {
CLASS
}
expect enum class As {
PROPERTY
}
expect annotation class JsonTypeInfo(
val use: Id,
val include: As,
val property: String,
val defaultImpl: KClass<*>,
val visible: Boolean
)
@JsonTypeInfo(Id.CLASS, As.PROPERTY, "type", JsonTypeInfo::class, false)
@Serializable
sealed class Item {
var id: Int? = null
var name: String? = null
}
jvm:
actual typealias Id = com.fasterxml.jackson.annotation.JsonTypeInfo.Id
actual typealias As = <http://com.fasterxml.jackson.annotation.JsonTypeInfo.As|com.fasterxml.jackson.annotation.JsonTypeInfo.As>
actual typealias JsonTypeInfo = com.fasterxml.jackson.annotation.JsonTypeInfo
unfortunately no way to use @OptionalExpectation
so I have to create a dummy actuals on JS target as well:
actual enum class Id {
CLASS
}
actual enum class As {
PROPERTY
}
actual annotation class JsonTypeInfo(actual val use: Id, actual val include: As, actual val property: String, actual val defaultImpl: KClass<*>, actual val visible: Boolean)