getElementDescriptor
Retrieves the descriptor of the child element for the given index. For the property of type T
on the position i
, getElementDescriptor(i)
yields the same result as for T.serializer().descriptor
, if the serializer for this property is not explicitly overridden with @Serializable(with = ...
)`, Polymorphic or Contextual. This method can be used to completely introspect the type that the current descriptor describes.
Example:
@Serializable
@OnClassSerialAnnotation
class Nested(...)
@Serializable
class Outer(val nested: Nested)
val outerDescriptor = Outer.serializer().descriptor
outerDescriptor.getElementDescriptor(0).serialName // Returns "Nested"
outerDescriptor.getElementDescriptor(0).annotations // Returns [@OnClassSerialAnnotation]
Content copied to clipboard
Throws
for illegal index values.
if the current descriptor does not support children elements (e.g. is a primitive).