CodecProvider

@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class CodecProvider(val externalTypes: Array<Json.ExternalType> = [])

Creates an object implementing the annotated interface which in turn extends JsonCodecProvider and no other interfaces. That object can be accessed using JsonCodecProvider.Companion.generated. It provides all codecs which have been generated using @Json annotations. The annotated interface also specifies the JsonCodingContext type being used by all generated codecs.

Note that only one codec provider can be created per module, and it must not be generic.

Example

@Json.CodecProvider
interface ExampleJsonCodecProvider : JsonCodecProvider<MyCodingContext>

val provider = JsonCodecProvider.generated(ExampleJsonCodecProvider::class)

Properties

Link copied to clipboard

Defines additional types for which codecs should be generated but which are not part of the same module as the annotated interface.