Reads a file in the current working directory or a String as a plain text YAML file. It uses SnakeYAML as YAML processor. The returned objects are standard Java objects like List, Long, String, ...: bool: [true, false, on, off] int: 42 float: 3.14159 list: ['LITE', 'RES_ACID', 'SUS_DEXT'] map: {hp: 13, sp: 5}
Fields:file
:
Optional path to a file in the workspace to read the YAML datas from.
text
:
An Optional String containing YAML formatted datas.
These are added to the resulting object after file
and so will overwrite any value already present if not a new YAML document
Examples:
With only one YAML document :
With several YAML documents :
def datas = readYaml text: """
something: 'my datas'
size: 3
isEmpty: false
"""
assert datas.something == 'my datas'
assert datas.size == 3
assert datas.isEmpty == false
With file dir/my.yml containing
def datas = readYaml text: """
---
something: 'my first document'
---
something: 'my second document'
"""
assert datas.size() == 2
assert datas[0].something == 'my first document'
assert datas[1].something == 'my second document'
something: 'my datas'
:
def datas = readYaml file: 'dir/my.yml', text: "something: 'Override'"
assert datas.something == 'Override'