encode

fun TomlEncoder.encode(value: Any): TomlValue

Encodes the given Kotlin value to as into a TomlValue using the receiver TomlEncoder. If the value can't be encoded, a TomlException.EncodingError is thrown.


Kotlin types can be encoded into TOML types as follows:

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

Note that as TOML does not have the concept of null, any null values present in encoded lists or maps are ignored.