encoders

fun encoders(types: Set<KClass<*>>, json: Json = defaultJson): ValueEncoderRegistry(source)

Generates and registers encoders for a set of types, including their sealed subclasses, with a given JSON serializer.

Return

A ValueEncoderRegistry populated with the generated encoders for the provided types and their subclasses.

Parameters

types

A set of Kotlin classes for which encoders are generated. The classes may include sealed classes.

json

The JSON configuration to be used for serialization. Defaults to defaultJson.


fun <T : @Serializable Any> encoders(clazz: KClass<T>, subclasses: Set<KClass<*>> = emptySet(), json: Json = defaultJson): List<Pair<KClass<*>, ValueEncoder<T>>>(source)

Generates encoders for a given class and its optional subclasses using the specified JSON configuration.

Return

A list of pairs, where each pair consists of a KClass and its corresponding ValueEncoder.

Parameters

clazz

The main Kotlin class for which an encoder is generated. This class must be serializable.

subclasses

A set of subclasses of the specified class for which the same encoder is generated. Defaults to an empty set.

json

The JSON configuration to be used for serialization and deserialization. Defaults to defaultJson.