How do I parse a YAML file in groovy?

后端 未结 2 943
星月不相逢
星月不相逢 2021-01-01 10:16

say if you have a file called example.yaml which contains the following: - subject: maths.

How do i grab the string after - subject

2条回答
  •  抹茶落季
    2021-01-01 10:57

    FWIW, the upcoming (as time of this writing) Groovy version 3.0 has direct support for yaml: http://docs.groovy-lang.org/next/html/api/groovy/yaml/package-summary.html with the traditional YamlSlurper / YamlBuilder combo You could always switch to this not-yet-officially-released version.

    [Edited] that version 3.0.x is now officially available, with the groovy.yaml package http://docs.groovy-lang.org/latest/html/api/groovy/yaml/package-summary.html

提交回复
热议问题