Write TOML to a file in the current working directory, or to a String.
Fields:toml
:
The object to write. Can be Map implementation.
file
(optional):
Optional path to a file in the workspace to write to.
If provided, then returnText
must be false
or omitted.
It is required that either file
is provided, or returnText
is true
.
returnText
(optional):
Return the TOML as a string instead of writing it to a file. Defaults to false
.
If true
, then file
must not be provided.
It is required that either file
is provided, or returnText
is true
.
Example:
Writing to a file:
Writing to a string:
def amap = ['something': 'my datas',
'size': 3,
'isEmpty': false]
writeTOML file: 'data.toml', toml: amap
def read = readTOML file: 'data.toml'
assert read.something == 'my datas'
assert read.size == 3
assert read.isEmpty == false
def amap = ['something': 'my datas',
'size': 3,
'isEmpty': false]
String toml = writeTOML returnText: true, toml: amap
def read = readTOML text: toml
assert read.something == 'my datas'
assert read.size == 3
assert read.isEmpty == false