Guest User

Untitled

a guest
Jun 24th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. // g100pon #87 YAML
  2. //
  3. @Grab(group='net.java.dev', module='jvyaml', version='0.2.1')
  4. import org.jvyaml.YAML
  5.  
  6. def yamlData = """
  7. - title: なんとかのテストをする
  8. node:
  9. - title: ほげほげ
  10. node:
  11. - title: なんとかがなんとかでなんとかする
  12. cond: これこれ,こうゆう条件だ。
  13. expect: こうなってくれ。
  14. - title: あれがこれでこうなる
  15. cond: こうゆう条件だ。
  16. expect: こうなるに違いない
  17.  
  18. - title: Foo Bar Boo
  19. node:
  20. - title: なんとかがなんとかでなんとかする
  21. cond: これこれ,こうゆう条件だ。
  22. expect: こうなってくれ。
  23.  
  24. - title: これもテストしないと
  25. """
  26.  
  27. // どうゆうワケか,File.newReader()だとYAMLがパースに失敗する
  28. YAML.load(yamlData).eachWithIndex {
  29. it, index ->
  30. println "$index : $it.title"
  31. it.node.eachWithIndex { n1, idx1 ->
  32. println "$index-$idx1 : $n1.title"
  33. n1.node.eachWithIndex { n2, idx2 ->
  34. println "$index-$idx1-$idx2 : $n2.title"
  35. println "$n2.cond"
  36. println "$n2.expect"
  37. println "----"
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment