tm_tomlencode Function
tm_tomlencode encodes a given value to a string using TOML syntax.
This function maps Terramate language values to TOML values in the following way:
| Terramate type | TOML type |
|---|---|
string | String |
number | Float |
bool | Boolean |
list(...) | Array |
set(...) | Array |
tuple(...) | Array |
map(...) | Table |
object(...) | Table |
| Null value | Not supported* |
Because null values are not supported in TOML, they are not encoded, which means that tm_tomlencode(null) is an error and if null appear in any collection type, it's ignored or the field it sets is not encoded.
Example of null value:
tm_tomlencode({a = 1, b = null})
a = 1.0Examples
sh
tm_tomlencode([1, 2, 3])
[1.0, 2.0, 3.0]
tm_tomlencode({project = {name = "my app", version = "1.0.0"}})
[project]
name = 'my app'
version = '1.0.0'Related Functions
tm_tomldecodeperforms the opposite operation, decoding a TOML string to obtain its corresponding HCL value.