I am using snakeyaml to parse yaml file I've. Unfortunately I am facing strange error(please see below) and looking for help in this regard.
public class HelloYaml {
@SuppressWarnings("unchecked")
public static def void main(String[] args) throws FileNotFoundException {
val yaml = new Yaml(new Constructor());
System.out.println(yaml.dump(yaml.load(new FileInputStream(new File(
"HelloYaml.yaml")))));
val value = yaml.load(new FileInputStream(new File("HelloYaml.yaml"))) as Map<String, User>
for (key : value.keySet()) {
println ("key:" + key)
}
val userinstace = value.get("d1")
println("user" + userinstace)
}
def static test(Map<Integer, Integer> map) {
val list = new ArrayList<Integer>(map.values);
println (list.get(0))
}
@org.eclipse.xtend.lib.annotations.Data static class Users
{
Map<String, User> map
}
}
@org.eclipse.xtend.lib.annotations.Data class User {
String name;
Integer age;
}
Error: Exception in thread "main" java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to com.avin.yaml.reader.User
at com.avin.yaml.reader.HelloYaml.main(HelloYaml.java:93)