// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package yamlproc;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Map;

import org.yaml.snakeyaml.Yaml;

public class SnakeTree {
    public static void main(String[] args) throws IOException {
        Yaml parser = new Yaml();
        @SuppressWarnings("unchecked")
        Map<String, Object> cfg = (Map<String, Object>)parser.load(new FileInputStream("/work/demo1.yaml"));
        @SuppressWarnings("unchecked")
        Map<String, Object> ab = (Map<String, Object>)cfg.get("ab");
        @SuppressWarnings("unchecked")
        Map<String, Object> de = (Map<String, Object>)cfg.get("de");
        int a = (Integer)ab.get("a");
        int b = (Integer)ab.get("b");
        int c = (Integer)cfg.get("c");
        String d = (String)de.get("d");
        String e = (String)de.get("e");
        String f = (String)cfg.get("f");
        System.out.printf("%d %d %d %s %s %s\n", a, b, c, d, e, f);
    }
}
