jean
05/23/2022, 1:06 PMinterface DeviceAttribute<T> {
val name: String
val value: T
}
@SharedImmutable
internal val module = SerializersModule {
polymorphic(baseClass = DeviceAttribute::class, baseSerializer = null) {
subclass(AlarmEntryDevice::class)
default { Unknown.serializer() }
}
}
@Serializable
data class Device(
val id: String,
val name: String,
val icon: String,
val iconOptions: List<String>,
val attributes: List<DeviceAttribute<*>> = emptyList(),
val profiles: List<ActiveProfileMode>?,
)
But I get this error Serializer has not been found for type 'Any?'. To use context serializer as fallback, explicitly annotate type or property with @Contextual
Adding the annotation doesn’t change anything though. What should I do?Dominaezzz
05/23/2022, 5:26 PMjean
05/23/2022, 7:14 PMDominaezzz
05/23/2022, 7:15 PMDominaezzz
05/23/2022, 7:16 PMT
are there? Maybe you can hard code them? Like StringDeviceAttribute
jean
05/23/2022, 7:19 PMDominaezzz
05/23/2022, 7:20 PMkotlinx.serialization
to know which value of T
to use when deserialising.Dominaezzz
05/23/2022, 7:20 PMjean
05/23/2022, 7:22 PMSerializersModule
to fix itephemient
05/23/2022, 10:05 PM