So I discovered the Groovy Library for JYaml, which allows you to instantiate classes from YAML files. Here is the example they give:
@Grab('org.jyaml:jyaml:1.3')
import org.ho.yaml.*
class Staff {
def firstname, lastname, position
}
input = '''
firstname: John
lastname: Connor
position: Resistance Leader
'''
Staff s = Yaml.loadType(input, Staff)
println s.dump()
// => <Staff@c05d3b firstname=John lastname=Connor position=Resistance Leader>
----EDIT----
As stated in the comments, JYAML
is no longer being supported and SnakeYAML
is the way to go for parsing YAML files. See the SnakeYAML examples here.