get
Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by the type parameter T
. If decoding is not possible, a TomlException.DecodingError is thrown. If there is no value at the given path, null
is returned.
As an example, given the following TOML:
[[ user ]]
name = "Alice"
passwords = ["password123", "qwerty"]
[[ user ]]
name = "Bob"
passwords = ["correct horse battery staple"]
A call to tomlDocument.get<List<String>>("user", "name")
will return listOf("Alice", "Bob")
.
Nested lists of values may be flattened, if necessary to make decoding into the desired type possible. For instance, while tomlDocument.get<List<List<String>>>("user", "passwords")
will return listOf(listOf("password123", "Bob"), listOf("correct horse battery staple"))
, tomlDocument.get<List<String>>("user", "passwords")
will automatically flatten the list to fit the given type parameter, and return listOf("password123", "qwerty", "correct horse battery staple")
.
Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by T
using the given custom TOML decoder.
Look up the value(s) at the given path in the receiver TOML structure, then decode them into the type given by targetKType
using the given custom TOML decoder. targetKType
and T
should correspond to the same type, or the behavior of get
is undefined.