getElementName
Returns a positional name of the child at the given index. Positional name represents a corresponding property name in the class, associated with the current descriptor.
Do not confuse with serialName, which returns class name:
package my.app
@Serializable
class User(val name: String)
val userDescriptor = User.serializer().descriptor
userDescriptor.serialName // Returns "my.app.User"
userDescriptor.getElementName(0) // Returns "name"
Content copied to clipboard
Throws
for an illegal index values.
if the current descriptor does not support children elements (e.g. is a primitive)