Hi, has there been any movement around nested poly...
# serialization
s
Hi, has there been any movement around nested polymorphism? My current use case is data that looks like this:
Copy code
{
  "type": "user",
  "some_other_field": "some_other_value",
  ...
}
where in the case of a
User
, the content of
some_other_field
indicates a different subclass to be used to deserialize it. This has an example in the docs: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md#content-based-polymorphic-deserialization but this doesn't play nicely if it's nested in something else. Stripped-down/simplified version of what I have now:
Copy code
@Serializable
sealed class Base

@Serializable(with = ContentBasedUserDeserializer::class)
@SerialName("user")
sealed class User : Base()

@Serializable
data class FirstUserType : User()
I found an issue on GitHub about nested polymorphism, but it says it would be covered in 1.x and hasn't been updated in 4 years. If what I'm doing right now is not supported, is there a workaround to deserialize the data I have now?
Update: I managed to hack it together myself using multiple
JsonContentPolymorphicSerializer
s.