Is there a way to know if a SerialDescriptor defin...
# serialization
g
Is there a way to know if a SerialDescriptor defines a class that is a nested class of another serialized class?
Copy code
@Serializable @SerialName("Foo") data class Foo(foo: Int) {
  @Serializable data class Bar(bar: Int)
}
I'd like to avoid describing a SerialName annotation for Bar and be able to use the serial name "Foo.Bar" in my use case.
a
I think it’s not possible via the general SerialDescriptor properties, the information is not detailed enough. It might be possible by using the captured KClass https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.descriptors/-serial-descriptor/#-1705787227%2FProperties%2F1625214593, but that would be reliant on reflection, and that might not be available on all Kotlin targets. Possibly you could implement something yourself using a custom
@SerialInfo
annotation https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-serial-info/
g
Thank you Adam, I'll have a look with capturedKClass, that could definitely help! (only targeting JVM for now)
🧑‍🎤 1