decode

inline fun <T : Any> TomlValue.decode(): T

Decodes the receiver TOML value to the type indicated by type parameter T using the default TOML decoder. If the value can't be decoded into the target type, a TomlException.DecodingError is thrown.


TOML types can be decoded to Kotlin types as follows:

Additionally, any subclass of TomlValue can always be decoded into itself.

fun <T : Any> TomlValue.decode(type: KType): T

Decodes the receiver TOML value into a value of the type corresponding to the given KType. T and type should correspond to the same type, or the behavior of decode is undefined.

inline fun <T : Any> TomlValue.decode(decoder: TomlDecoder): T

Decodes the receiver TOML value into a value of type T, using the given custom decoder.

fun <T : Any> TomlValue.decode(decoder: TomlDecoder, type: KType): T

Decodes the receiver TOML value into a value of the type corresponding to the given KType, using the given custom decoder. T and type should correspond to the same type, or the behavior of decode is undefined.