annotations
Returns serial annotations of the associated class. Serial annotations can be used to specify additional metadata that may be used during serialization. Only annotations marked with SerialInfo are added to the resulting list.
Do not confuse with getElementAnnotations:
@Serializable
@OnClassSerialAnnotation
class Nested(...)
@Serializable
class Outer(@OnPropertySerialAnnotation val nested: Nested)
val outerDescriptor = Outer.serializer().descriptor
outerDescriptor.getElementAnnotations(0) // Returns [@OnPropertySerialAnnotation]
outerDescriptor.getElementDescriptor(0).annotations // Returns [@OnClassSerialAnnotation]
Content copied to clipboard