I test SnakeYAML library to read .yaml documents. I have read Example 2.27. Invoice from http://yaml.org/spec/1.1/ and I get object:
System.out.println(content);
Yaml yaml = new Yaml();
Object o = yaml.load(content);
where content is String loaded from file using Files.readAllBytes, encoding.decode (encoding is StandardCharsets.UTF_8)
Reflection gaves me that o is type of java.util.LinkedHashMap and I can iterate over them:
Set entrySet = o.entrySet();
Iterator it = entrySet.iterator();
System.out.println("LinkedHashMap entries : ");
while (it.hasNext())
{
Object entry = it.next();
System.out.println(entry);
}
Reflection return that type of entry is LinkedHashMap$Entry. But is problem: internal class LinkedHashMap$Entry is private and I can't declare objects this type. How I can get pair from entry, iterator or entrSet?