That is why all the YAML parsers require additional configuration to parse a collection. SnakeYAML is using TypeDescription to detect the runtime class.
Fortunately if the collection is a JavaBean property there is a way to detect the runtime class. Thanks to Benjamin Bentmann for the idea.
Check the issue 25.
JavaBeanLoaderbeanLoader = new JavaBeanLoader (ListBean.class);
ListBean parsed = beanLoader.load(output);
These 2 lines parse ListBean with properly created Developer instances. Parsing JavaBeans with SnakeYAML has become even simpler!
At the moment only List is supported. Does anybody need to extend the support to Set and Map ?
4 comments:
Sets and Maps support would be nice, may be not high priority.
What about dumping ?
Does snakeyaml omit explicit tag in case real class of the object is the same as generic type for the collection ? (sorry for the question. I should know it myself, but had no time to play with snakeyaml recently. hope to do it ASAP)
At the moment dumping emits redundant global tags. I would like to fix it after I finish the parsing.
Release 1.5 of SnakeYAML shall contain the complete implementation.
Dumping and parsing work as expected. All the collections are supported.
SnakeYAML 1.5 is ready to go!
yep. I have noticed from the project's rss.
nice work. thx
Post a Comment