groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dimitar Vassilev <dimitar.vassi...@gmail.com>
Subject parsing YAML with snakeyaml
Date Wed, 21 Dec 2016 19:58:49 GMT
Good evening/morning/day,
Quick one how can I parse a YAML file with groovy and snakeyaml

I have a nested hash YAML like:

pkgcolls:
  pkgcol1:
     software:Foo
         version:baz
  pkgcol2:
     software:baz
         version:Foo

In Ruby I can do something like in the irb/file
require 'yaml'
thing = YAML.load_file('some.yml')
puts thing.inspect

How can I do similar thing in groovy using

import org.yaml.snakeyaml.DumperOptions
import org.yaml.snakeyaml.Yaml

and the yaml.load(object) function?
I would like to loop through the YAML structure and figure out which kind
of loop to use.
I'm interested in dealing directly with the pkgcol(1-N) attributes directly
if possible.
Thanks

Mime
View raw message