Toml Mapper
A bidirectional TOML transcoder, capable of converting TomlValues into Kotlin values, and vice versa.
A transcoder is intended to make your life easier by keeping custom mappings in sync between your encoder and decoder. Unless you need custom en/decoder functions, using a transcoder instead of a separate encoder and decoder is highly recommended.
Functions
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 cc.ekblad.toml.model.TomlException.DecodingError is thrown.
Like decode, but will fill in any missing fields from the defaultValue. Appropriate for use cases such as configuration files, where you may not want to force the user to configure every last thing, but just override the bits they want to customize.
Encodes the given Kotlin value to as into a TomlValue using the receiver TomlEncoder. If the value can't be encoded, a cc.ekblad.toml.model.TomlException.EncodingError is thrown.
Extensions
Like decode, but fills in any values missing from the input string with values from the given defaultValue.
Like decode, but fills in any values missing from the input stream with values from the given defaultValue.
Like decode, but fills in any values missing from the input file with values from the given defaultValue.
Serializes given value into a valid TOML document and writes it to the given Appendable. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.
Serializes given value into a valid TOML document and writes it to the given OutputStream. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.
Serializes given value into a valid TOML document and writes it to the file indicated by the given Path. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.
Encodes the given value into a valid TOML document. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.
Encodes the given value into a valid TOML document and serializes it into a string. If value does not serialize to a valid TOML document (i.e. a map of zero or more keys), an TomlException.SerializationError is thrown.