Skip to content

Instantly share code, notes, and snippets.

@rdmueller
Created April 3, 2016 20:11
Show Gist options
  • Save rdmueller/545286b23c76a80906f356d66ffa199e to your computer and use it in GitHub Desktop.
Save rdmueller/545286b23c76a80906f356d66ffa199e to your computer and use it in GitHub Desktop.
// simple script which shows how to read and write YAML with Groovy
@Grab("org.yaml:snakeyaml:1.16")
import org.yaml.snakeyaml.Yaml
def yamlData = """
Time: 2001-11-23 15:01:42 -5
User: a Test
# Multiline String
Warning:
This is an error message
for the log file
Boolean: True
address:
street: sesamestreet 5
city: Hollywood
"""
def dataFromYaml = new Yaml().load(yamlData)
println dataFromYaml
Yaml yaml = new Yaml();
println yaml.dumpAsMap(dataFromYaml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment