avro-kotlin / avro4k

Avro format support for Kotlin
Apache License 2.0
188 stars 36 forks source link

Is it possible to serialize to GenericRecord without a SerializationStrategy<T>? #136

Closed minionOfZuul closed 1 year ago

minionOfZuul commented 1 year ago

I have a use case where I need to work strictly with GenericRecords - in other words, I have no data class from which to derive a serializer. I've combed through the docs and the API and I don't see a straightforward way to give Avro4k an instance and a schema and get back a GenericRecord. Is there such a thing?

thake commented 1 year ago

If you don't have an @Serializable annotated data class, you'll have to provide a custom serializer so that kotlinx.serialization knows how to serialize the provided instance.

Does this help you? Maybe I have got your question wrong. Maybe you can give some pseudo code of what you want to achieve.