Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 27th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package test.yaml
  2.  
  3. import org.yaml.snakeyaml.Yaml
  4. import org.yaml.snakeyaml.constructor.Constructor
  5. import org.yaml.snakeyaml.introspector.BeanAccess
  6.  
  7. case class Project(name: String, url: String)
  8.  
  9. object App {
  10.  
  11.   def main(args: Array[String]) {
  12.      val yaml = new Yaml(new Constructor(classOf[Project]))
  13.      yaml.setBeanAccess(BeanAccess.FIELD)
  14.      val project = yaml.load("name : abc\nurl : def").asInstanceOf[Project]
  15.      println("YAML READ DATA: " + project)
  16.   }
  17.  
  18. }