Skip to content

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 typeTOML type
stringString
numberFloat
boolBoolean
list(...)Array
set(...)Array
tuple(...)Array
map(...)Table
object(...)Table
Null valueNot 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.0

Examples

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'
  • tm_tomldecode performs the opposite operation, decoding a TOML string to obtain its corresponding HCL value.