Closed FranziskusW closed 9 months ago
As a minimal example for reproduction, you can try this:
import kotlinx.serialization.SerializationException
import kotlinx.serialization.builtins.MapSerializer
import kotlinx.serialization.descriptors.PolymorphicKind
import kotlinx.serialization.descriptors.StructureKind
import kotlinx.serialization.builtins.serializer
println(
when (MapSerializer(String.serializer(), String.serializer()).descriptor.kind) {
is StructureKind -> "StructureKind.CLASS"
is PolymorphicKind -> "PolymorphicKind"
else -> throw SerializationException("Unsupported root element passed to root record encoder")
}
)
Is this a restriction of AVro itself? Not allowing a Map as root element?
Currently avro4k only supports data classes as roots. But it should be possible to also support all other types. Do you want to give it a try and provide a pr?
Closing stale issue. By the way, we are planning to handle non-record values
Closing this issue, as it will be covered by #187 and #114
I am using
Avro.default.toRecord(serializer, data)
with aMapSerializer(String.serializer(), String.serializer()
. As it returnskotlinx.serialization.SerializationException: Unsupported root element passed to root record encoder
I investigated and found the following snippet inIt seems that
StructureKind.CLASS
is the culprit. It contains an object of that type, but the kotlinis
-comparator expects a type.