getElementIndex
Returns an index in the children list of the given element by its name or CompositeDecoder.UNKNOWN_NAME if there is no such element. The resulting index, if it is not CompositeDecoder.UNKNOWN_NAME, is guaranteed to be usable with getElementName.
Example:
@Serializable
class User(val name: String, val alias: String?)
val userDescriptor = User.serializer().descriptor
userDescriptor.getElementIndex("name") // Returns 0
userDescriptor.getElementIndex("alias") // Returns 1
userDescriptor.getElementIndex("lastName") // Returns CompositeDecoder.UNKNOWN_NAME = -3
Content copied to clipboard