Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // g100pon #87 YAML
- //
- @Grab(group='net.java.dev', module='jvyaml', version='0.2.1')
- import org.jvyaml.YAML
- def yamlData = """
- - title: なんとかのテストをする
- node:
- - title: ほげほげ
- node:
- - title: なんとかがなんとかでなんとかする
- cond: これこれ,こうゆう条件だ。
- expect: こうなってくれ。
- - title: あれがこれでこうなる
- cond: こうゆう条件だ。
- expect: こうなるに違いない
- - title: Foo Bar Boo
- node:
- - title: なんとかがなんとかでなんとかする
- cond: これこれ,こうゆう条件だ。
- expect: こうなってくれ。
- - title: これもテストしないと
- """
- // どうゆうワケか,File.newReader()だとYAMLがパースに失敗する
- YAML.load(yamlData).eachWithIndex {
- it, index ->
- println "$index : $it.title"
- it.node.eachWithIndex { n1, idx1 ->
- println "$index-$idx1 : $n1.title"
- n1.node.eachWithIndex { n2, idx2 ->
- println "$index-$idx1-$idx2 : $n2.title"
- println "$n2.cond"
- println "$n2.expect"
- println "----"
- }
- }
- }
Add Comment
Please, Sign In to add comment