getElementName

abstract fun getElementName(index: Int): String(source)

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"

Throws

for an illegal index values.

if the current descriptor does not support children elements (e.g. is a primitive)