Hi! I am using kotlinx.serialization and am running into some issues with regards to generic values in data classes. I have roughly the following:
Copy code
@Serializable
data class BaseResult<T>(val data: T, val foo: Int)
@Serializable
data class SomeData(val bar: String)
// Then when decoding incoming json I do:
val response = Json { ignoreUnknownKeys = true }
.decodeFromString<BaseResult<SomeData>>(responseBody)
When doing this I get the following error:
Copy code
Serializer for class 'SomeData' is not found.
kotlinx.serialization.SerializationException: Serializer for class 'SomeData' is not found.
Mark the class as @Serializable or provide the serializer explicitly.
Jonathan Olsson
03/25/2021, 8:46 AM
Hmm. Actually this was due to gradle (i.e. me) not properly applying the serialization plugin. The gradle pluginManagement is very, very confusing and subtle to me... š
a
araqnid
03/25/2021, 11:49 AM
you usually donāt need pluginManagement{}, just put the plugin into a plugins{} block at the top of the build file. For multi-module projects, only put the version number in the root build file (with āapply falseā if the root project has no code)