I am pretty new to scala. I was trying to parse a Yaml File using snakeyaml in scala. I am getting the data but it is in the form of an object. I can convert the object ot string but it defeats the whole purpose of using the Yaml.
e.g. the file i am using is "abcd.yaml" with data
aa:
- x
- y
bb: z
my code goes like this:
import java.io.{File, FileInputStream}
import org.yaml.snakeyaml.Yaml
def parseYaml(){
val ios = new FileInputStream(new File("abcd.yaml"))
val yaml = new Yaml()
val obj = yaml.load(ios)
}
but here I am getting an object and I cannot use the values inside. Any solution?
I got the solution, it's to cast to java maps instead of scala maps:
Just use
asInstanceOf[java.util.Map[String, Any]
and it works like a charm. The solution is to call load like this: