<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4336104534924908200</id><updated>2011-07-08T00:03:19.098-07:00</updated><title type='text'>to YAML or not to YAML: that is a question...</title><subtitle type='html'>can YAML become a mean to make programming languages close friends?</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-2986217412523228218</id><published>2011-01-28T09:27:00.000-08:00</published><updated>2011-01-29T02:21:22.672-08:00</updated><title type='text'></title><content type='html'>Recently Natan Sweet the author of the YamlBeans library left a comment on the wiki page in SnakeYAML stating that the library comparison is &lt;a href="http://code.google.com/p/snakeyaml/wiki/Comparison"&gt;very poor&lt;/a&gt;. Indeed I am biased and I may not have precise and up-to-date information. We shall try to create a non-biased version of such a comparison table taking all the arguments into account. I hope together with Natan we can deliver a better version.&lt;br /&gt;&lt;br /&gt;In the mean time I try to clarify some of my statements.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I clearly state where I see that YamlBeans &lt;a href="http://code.google.com/p/snakeyaml/wiki/Comparison#Deviation_from_the_specification"&gt;does not follow the specification&lt;/a&gt;. When I tried YamlBeans some time ago it trimmed trailing spaces from scalars in literal style. May it has been fixed in the meantime. I may check it.&lt;/li&gt;&lt;li&gt;How can YamlBeans prove it works with Java 5 if it cannot be built with Java 5? How I can be sure that no Java 6 methods are called ?&lt;/li&gt;&lt;li&gt;Indeed I made a mistake stating that line number is not reported in case of an error. I overlooked it because it is sometimes shown as part of another exception deep in the stack trace. SnakeYAML together with line number shows some error context - a couple of lines of the YAML document to clearly identify the problem.&lt;/li&gt;&lt;li&gt;The quality of the YamlBeans parser is indeed higher then the one from JvYaml. YamlBeans is not mentioned next to JvYaml's bugs anymore. I am sorry.&lt;/li&gt;&lt;li&gt;By "Low level API" I understand the agreed way to get the low details of the underlying YAML document. It means that &lt;a href="http://yaml.org/spec/1.1/#id859333"&gt;this API&lt;/a&gt; must expose &lt;a href="http://yaml.org/spec/1.1/#id861435"&gt;Nodes&lt;/a&gt; and Events which part of the specification. Of course YamlBeans has some low-level details. Are they described anywhere ? Can they be used ? For instance, recently &lt;a href="http://groups.google.com/group/snakeyaml-core/browse_thread/thread/39f573505aeb8217"&gt;JRuby began to use SnakeYAML&lt;/a&gt; because its low-level API is fully compatible with the standard Ruby parser.&lt;/li&gt;&lt;li&gt;The fact that something can be done does not mean it is done. It took a reasonable amount of time and efforts to deploy SnakeYAML artifacts into a public repository. YamlBeans has not finished the task yet. When you use Maven then the source is automatically downloaded and added to your project in Eclipse by maven script. This is very convenient. &lt;/li&gt;&lt;/ol&gt;In the meantime I have created a &lt;a href="http://code.google.com/p/yamlbeans/issues/list"&gt;few issues&lt;/a&gt; for YamlBeans to show my points. I think it is better discuss it one-by-one to avoid any misunderstanding in the future.&lt;br /&gt;&lt;br /&gt;Once I have time I will try to prepare another version of the comparison table and before I publish it I will get in touch with Natan to avoid mistakes.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-2986217412523228218?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/2986217412523228218/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=2986217412523228218' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/2986217412523228218'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/2986217412523228218'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2011/01/recently-natan-sweet-author-of.html' title=''/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-3274157444548209874</id><published>2010-03-23T02:58:00.000-07:00</published><updated>2010-03-23T03:29:24.068-07:00</updated><title type='text'>TODO for SnakeYAML 1.7</title><content type='html'>I have recently received 3 enhancement requests for SnakeYAML:&lt;br /&gt;&lt;br /&gt;1. Provide a simplified interface to process configuration files. No JavaBeans. No anchors and aliases. No implicit types. It can be used in projects like &lt;a href="http://wiki.github.com/mrdon/maven-yamlpom-plugin/"&gt;YAML Maven POM&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;2. Use &lt;a href="http://tux2323.blogspot.com/2010/03/proposal-snakeyaml-annotation-yaml.html"&gt;annotations&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;3. Introduce &lt;a href="http://code.google.com/p/snakeyaml/issues/detail?id=57"&gt;namespaces&lt;/a&gt; for tags. This is requested to support JRuby where a YAML document may refer to either Ruby or Java instances.&lt;br /&gt;&lt;br /&gt;All three require a substantial implementation.&lt;br /&gt;What I miss is the feedback from those who may need these features. More real-world examples would greatly help to see the scope of the change.&lt;br /&gt;Do you think they are useful ? Do you have an idea how the API may look like ? Feel free to provide your feedback.&lt;br /&gt;&lt;br /&gt;Use &lt;a href="http://vomos.blogspot.com/"&gt;the poll&lt;/a&gt; to indicate the features you want to go first.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-3274157444548209874?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/3274157444548209874/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=3274157444548209874' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/3274157444548209874'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/3274157444548209874'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2010/03/todo-for-snakeyaml-17.html' title='TODO for SnakeYAML 1.7'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-6859390390611906405</id><published>2009-12-08T05:29:00.000-08:00</published><updated>2009-12-08T07:29:56.907-08:00</updated><title type='text'>Ruby and SnakeYAML</title><content type='html'>Recently I have seen a post &lt;a href="http://blog.bytemine.net/2009/12/07/yaml-in-java-and-ruby-welcome-yamlbeans"&gt;yaml in Java and Ruby&lt;/a&gt; where SnakeYAML was not chosen as the  YAML parser.&lt;br /&gt;The message is:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Because snakeyaml seems to have a syntactical problem with this &lt;/span&gt;&lt;span style="font-style: italic;" class="caps"&gt;YAML&lt;/span&gt;&lt;span style="font-style: italic;"&gt; document we did no further investigations on snakeyaml.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But the real problem is that the document contains tags and the parser must be instructed how to process them.&lt;br /&gt;Let us see what we can do.&lt;br /&gt;The document:&lt;pre&gt;--- !ruby/object:Test::Module::Object&lt;br /&gt;sub1: !ruby/object:Test::Module::Sub1&lt;br /&gt;  att1: []&lt;br /&gt;  att2: 0&lt;br /&gt;  att3: []&lt;br /&gt;sub2: !ruby/object:Test::Module::Sub2&lt;br /&gt;  att1: MyString&lt;br /&gt;  att2:&lt;br /&gt;  - entry1&lt;br /&gt;  att3: 12345&lt;br /&gt;&lt;/pre&gt;We do not need &lt;a href="http://code.google.com/p/snakeyaml/source/browse/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java"&gt;a lot of code&lt;/a&gt; to parse the document:&lt;br /&gt;&lt;pre&gt;Constructor con = new Constructor(TestObject.class);&lt;br /&gt;con.addTypeDescription(new TypeDescription(TestObject.class, "!ruby/object:Test::Module::Object"));&lt;br /&gt;con.addTypeDescription(new TypeDescription(Sub1.class, "!ruby/object:Test::Module::Sub1"));&lt;br /&gt;con.addTypeDescription(new TypeDescription(Sub2.class, "!ruby/object:Test::Module::Sub2"));&lt;br /&gt;Yaml yaml = new Yaml(new Loader(con));&lt;br /&gt;return (TestObject) yaml.load(input);&lt;br /&gt;&lt;/pre&gt;Let's create a YAML document:&lt;br /&gt;&lt;pre&gt;DumperOptions options = new DumperOptions();&lt;br /&gt;options.setExplicitStart(true);&lt;br /&gt;options.setExplicitRoot(Tags.MAP);&lt;br /&gt;Yaml yaml2 = new Yaml(options);&lt;br /&gt;String output = yaml2.dump(result);&lt;br /&gt;&lt;/pre&gt;This is the result:&lt;br /&gt;&lt;pre&gt;---&lt;br /&gt;sub1:&lt;br /&gt;  att1: []&lt;br /&gt;  att2: 0&lt;br /&gt;  att3: []&lt;br /&gt;sub2:&lt;br /&gt;  att1: MyString&lt;br /&gt;  att2: [entry1]&lt;br /&gt;  att3: 12345&lt;br /&gt;&lt;/pre&gt;As you can see no tags are used. Normally SnakeYAML tries to avoid emitting tags as much as possible to simplify inter-language communication. But it seems that dynamically typed languages do not have any other means to define a class of an instance as to use a tag.&lt;br /&gt;Let's emit the tags:&lt;br /&gt;&lt;pre&gt;DumperOptions options = new DumperOptions();&lt;br /&gt;options.setExplicitStart(true);&lt;br /&gt;Representer repr = new Representer();&lt;br /&gt;repr.addClassTag(TestObject.class, "!ruby/object:Test::Module::Object");&lt;br /&gt;repr.addClassTag(Sub1.class, "!ruby/object:Test::Module::Sub1");&lt;br /&gt;repr.addClassTag(Sub2.class, "!ruby/object:Test::Module::Sub2");&lt;br /&gt;Yaml yaml2 = new Yaml(new Dumper(repr, options));&lt;br /&gt;String output = yaml2.dump(result);&lt;br /&gt;&lt;/pre&gt;The document with tags:&lt;br /&gt;&lt;pre&gt;--- !ruby/object:Test::Module::Object&lt;br /&gt;sub1: !ruby/object:Test::Module::Sub1&lt;br /&gt;  att1: []&lt;br /&gt;  att2: 0&lt;br /&gt;  att3: []&lt;br /&gt;sub2: !ruby/object:Test::Module::Sub2&lt;br /&gt;  att1: MyString&lt;br /&gt;  att2: [entry1]&lt;br /&gt;  att3: 12345&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This document should be properly consumed by the Ruby parser. Unfortunately it requires to use the latest source from Mercurial. Current version (1.5) does not emit the tag for JavaBean properties even when the tag is explicitly defined. Either wait for the release after 1.5 or take the source !&lt;br /&gt;SnakeYAML can work with YAML documents coming from Ruby parser.&lt;br /&gt;&lt;br /&gt;Mission Accomplished.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-6859390390611906405?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/6859390390611906405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=6859390390611906405' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/6859390390611906405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/6859390390611906405'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/12/ruby-and-snakeyaml.html' title='Ruby and SnakeYAML'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-8061006554363254913</id><published>2009-11-03T02:09:00.000-08:00</published><updated>2009-11-03T02:31:03.603-08:00</updated><title type='text'>Java libraries for YAML</title><content type='html'>This is my overview of the state of different YAML libraries for Java. I do not claim it is complete (yes, I am biased) but it is my vision for today. Feel free to correct me.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;JvYaml&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;v=0.2.1&lt;/span&gt;: the project is dead. No issue is fixed. The developer is now maintaining another project - JvYAMLb&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;JvYAMLb &lt;/span&gt;is a YAML processing library for Java, used by JRuby, &lt;span style="font-style: italic;"&gt;v=0.2.5&lt;/span&gt;. I did not even evaluate the project because of a few dependencies on JRuby.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;JYaml&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;v=1.3&lt;/span&gt;: last release is more then 2 year old. Many open bugs. I do not know whether it is maintained. Google puts this library to the top. Does it mean that it is the most wide spread ?&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;YamlBeans&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;v=0.93&lt;/span&gt;: since the parser and emitter are based on the JvYaml implementation it does not cover the whole 1.1 specification.&lt;br /&gt;Implicit types are not supported (http://yaml.org/type/index.html)&lt;br /&gt;Implementation does not follow the recommended way (http://yaml.org/spec/1.1/#id859333)&lt;br /&gt;The document must be a JavaBean. Empty constructor is required. Immutable objects are not supported.&lt;/li&gt;&lt;/ul&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-weight: bold;"&gt;SnakeYAML&lt;/span&gt;, &lt;span style="font-style: italic;"&gt;v=1.5. &lt;/span&gt;Unique features:&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;- Complete 1.1 YAML spec is implemented&lt;br /&gt;- strong commitment to cross-language compatibility (as less global tags as possible)&lt;br /&gt;- comprehensive documentation&lt;br /&gt;- Maven 2 artifacts (including sources.jar and javadoc.jar)&lt;br /&gt;- complete support for recursive objects (they can be parsed and emitted)&lt;br /&gt;- 98% test coverage&lt;br /&gt;- support for immutable instances&lt;br /&gt;- collections in JavaBeans do not require global tags (other libraries need to configure additional runtime information which is required because of erasure)&lt;br /&gt;- readable error reporting (with line numbers)&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;In fact I am not aware of any feature which is present in any library but not implemented in SnakeYAML. Nevertheless Google puts JYaml much higher then SnakeYAML and YamlBeans has much more downloads then SnakeYAML.&lt;br /&gt;What is missing in SnakeYAML ? Why developers prefer to use another library ? What can be improved in SnakeYAML ?&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-8061006554363254913?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/8061006554363254913/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=8061006554363254913' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/8061006554363254913'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/8061006554363254913'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/11/java-libraries-for-yaml.html' title='Java libraries for YAML'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-7831586182684659309</id><published>2009-10-20T08:01:00.000-07:00</published><updated>2009-10-20T08:23:05.333-07:00</updated><title type='text'>Better support for type-safe collections</title><content type='html'>Java 5 introduced a nice feature - type-safe collections (generic collections). Unfortunately due to erasure the actual type is removed by the compiler and there is no way to detect the type of objects in a collection.&lt;br /&gt;That is why all the YAML parsers require additional configuration to parse a collection. SnakeYAML is using TypeDescription to detect the runtime class.&lt;br /&gt;Fortunately if the collection is a JavaBean property there is a way to detect the runtime class. Thanks to Benjamin Bentmann for the idea.&lt;br /&gt;Check &lt;a href="http://code.google.com/p/snakeyaml/issues/detail?id=25"&gt;the issue 25&lt;/a&gt;.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;JavaBeanLoader&lt;ListBean&gt; beanLoader = new JavaBeanLoader&lt;ListBean&gt;(ListBean.class);&lt;br /&gt;ListBean parsed = beanLoader.load(output);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;These 2 lines parse &lt;a href="http://code.google.com/p/snakeyaml/source/browse/src/test/java/examples/collections/TypeSafeListTest.java"&gt;ListBean &lt;/a&gt;with properly created Developer instances. Parsing JavaBeans with SnakeYAML has become even simpler!&lt;br /&gt;At the moment only List is supported. Does anybody need to extend the support to Set and Map ?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-7831586182684659309?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/7831586182684659309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=7831586182684659309' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/7831586182684659309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/7831586182684659309'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/10/better-support-for-type-safe.html' title='Better support for type-safe collections'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-2497584218739552351</id><published>2009-06-29T04:13:00.000-07:00</published><updated>2009-06-29T05:34:28.556-07:00</updated><title type='text'>Что же делать с рекурсивными объектами ?</title><content type='html'>На данный момент &lt;a href="http://code.google.com/p/snakeyaml/"&gt;SnakeYAML&lt;/a&gt; не умеет правильно работать с объектами, которые ссылаются на самих себя (напрямую или через другие объекты). Вот сама &lt;a href="http://code.google.com/p/snakeyaml/issues/detail?id=1"&gt;проблема&lt;/a&gt;. При этом имплементация сериализации (dumping) проще и это работает. Десериализация сложнее и  имплементация потребует значительных изменений в коде при создании объектов.&lt;br /&gt;Так как в настоящий момент у меня нет нужды работать с рекурсивными объектами, то никаких телодвижений в данном направлении не наблюдается. Если кому-нибудь захочется это починить, то все будут только рады.&lt;br /&gt;В своё время я спросил у разработчика PyYAML, как это там сделано. Кирилл дал очень полный и исчертывающий ответ. (Спасибо!) К сожалению, в Jav'e не доступны те средства, которые используются для этого в PyYAML - generators. Поэтому импортировать реализацию в SnakeYAML не получится.&lt;br /&gt;Для тех, кто не боится интересных задач привожу здесь ответ Кирилла:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Попробую объяснить так.  Нам дан ориентированный граф (YAML document) с выделенной вершиной - корнем документа.  У каждой вершины есть метка - tag.  Каждому тегу мы можем сопоставить конструктор - функцию, которая принимает в качестве параметра вершину графа и возвращает native object.  Задача состоит в том, чтобы преобразовать весь документ и вернуть native object соответствующий корню документа.&lt;br /&gt;&lt;br /&gt;Как это сделать?  Самый простой случай - когда alias-ы вообще не используются.  Тогда граф представляет из себя дерево, корень дерева - это корень документа.  Алгоритм преобразования дерева в объект можно представить так:&lt;br /&gt;&lt;br /&gt;чтобы преобразовать узел дерева:&lt;br /&gt;   для sequence node: преобразовываем узлы входящие в&lt;br /&gt;       последовательность (рекурсивно)&lt;br /&gt;   для mapping node: преобразовываем узлы входящие в&lt;br /&gt;       отображение (рекурсивно)&lt;br /&gt;   преобразовываем сам узел и возвращаем его.&lt;br /&gt;&lt;br /&gt;Не многим сложней и случай, когда alias-ы допускаются, но не создают циклов в графе.  В этом случае достаточно добавить в алгоритм проверку:&lt;br /&gt;&lt;br /&gt;   если узел уже преобразован, вернуть соответствующий объект.&lt;br /&gt;&lt;br /&gt;Проблема заключается в том, что делать, когда в документе есть циклы.&lt;br /&gt;Самый простой пример:&lt;br /&gt;&lt;br /&gt;--- &amp;A [ *A ]&lt;br /&gt;&lt;br /&gt;последовательность в которой один элемент - сама последовательность. Создать такую последовательность в Python-е можно так:&lt;br /&gt;&lt;br /&gt;seq = []&lt;br /&gt;seq.append(seq)&lt;br /&gt;&lt;br /&gt;Тут важно заметить, что создать рекурсивную структуру за один шаг невозможно.  Здесь процесс преобразования разделен на два шага: создание объекта и заполнение объекта.  Для создания объекта не используются объекты соответствующие другим вершинам графа.  Это подсказывает идею: сперва создать объекты соответствующие всем вершинам документа а затем заполнить их.&lt;br /&gt;&lt;br /&gt;Итак, мы разбиваем конструктор на две различные функции: создание и заполнение.  Для создания объекта не требуется знаний про другие вершины документа и соответствующие им объекты, для заполнения - требуются. Алгоритм выглядит так:&lt;br /&gt;&lt;br /&gt;для каждой вершины документа:&lt;br /&gt;   создать соответствующий объект.&lt;br /&gt;для каждой вершины документа:&lt;br /&gt;   заполнить соответствующий объект.&lt;br /&gt;&lt;br /&gt;Это решает задачу в том случае, если мы способны разбить таким образом каждый конструктор.  К сожалению, это не всегда возможно: для некоторых типов создание и заполнение объекта всегда производится в один шаг. Например, в Python-е есть тип tuple - неизменяемый список, содержимое которого можно указать лишь при создании объекта:&lt;br /&gt;&lt;br /&gt;t = (1, 2, 3)&lt;br /&gt;&lt;br /&gt;Это делает невозможным создание tuple содержащей саму себя, т.е. объект,&lt;br /&gt;соответствующий документу:&lt;br /&gt;&lt;br /&gt;--- !!python/tuple &amp;A [ *A ]&lt;br /&gt;&lt;br /&gt;невозможно построить.  Тем не менее, это не значит, что tuple не может входить в сложные рекурсивные структуры.  Например документ:&lt;br /&gt;&lt;br /&gt;-- !!python/tuple &amp;A [ [ *A ] ]&lt;br /&gt;&lt;br /&gt;можно преобразовать так:&lt;br /&gt;&lt;br /&gt;l = []&lt;br /&gt;t = (l,) # это конструктор tuple из одного элемента в Python-е&lt;br /&gt;l.append(t),&lt;br /&gt;return t&lt;br /&gt;&lt;br /&gt;а документ:&lt;br /&gt;&lt;br /&gt;--- &amp;A [ !!python/tuple [ *A ] ]&lt;br /&gt;&lt;br /&gt;так:&lt;br /&gt;&lt;br /&gt;l = []&lt;br /&gt;t = (l,)&lt;br /&gt;l.append(t)&lt;br /&gt;return l&lt;br /&gt;&lt;br /&gt;Интересно, что в обоих случаях создание объектов происходит одинаково.&lt;br /&gt;&lt;br /&gt;Итак, дело усложняется тем, что конструкторы бывают двух видов - такие, в которых создание объектов требует информации про другие вершины и такие - в которых создание и заполнение объекта можно разделить.  Что делать в этом случае?  Назовем вершину A зависимой от вершины B, если для создания объекта, соответствующего вершине A требуется знать объект, соответствующий вершине B.  Классифицировать зависимости в документе не сложно: если конструктор вершины разбивается на два шага: создание и заполнение, то вершина ни от кого не зависит.  Если же конструктор одношаговый, то вершина зависит от своих элементов.&lt;br /&gt;&lt;br /&gt;Далее, отсортируем все вершины так, чтобы B находилась перед A когда A зависит от B.  Это делается с помощью так называемой "топологической сортировки" - варианта поиска в глубину в графе.  Если вершины отсортированы в нужном порядке, то к ним можно применять конструкторы, зная что объекты, которые требуются для преобразования вершины к этому времени уже созданы.  Итак, окончательный алгоритм выглядит так:&lt;br /&gt;&lt;br /&gt;отсортировать вершины в порядке зависимостей, выдать ошибку если это невозможно.&lt;br /&gt;для каждой вершины в указанном порядке:&lt;br /&gt;   если вершина допускает многошаговый конструктор:&lt;br /&gt;       вызвать первый шаг конструктора - создание объекта&lt;br /&gt;   иначе:&lt;br /&gt;       вызвать конструктор&lt;br /&gt;для каждой вершины в указанном порядке:&lt;br /&gt;   если вершина допускает многошаговый конструктор:&lt;br /&gt;       вызвать второй шаг конструктора - заполнение объекта&lt;br /&gt;&lt;br /&gt;Как видно, пример с взаимно рекурсивными списком и tuple вполне соответствует этому алгоритму.  В PyYAML описанные шаги алгоритма не выражены явно, однако по сути используется именно такой подход.&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Буду безумно благодарен тому, кто не пожалеет времени перевести сие на английский, чтобы помочь желающим решить проблему.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-2497584218739552351?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/2497584218739552351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=2497584218739552351' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/2497584218739552351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/2497584218739552351'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/06/blog-post.html' title='Что же делать с рекурсивными объектами ?'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-3936826424736282531</id><published>2009-06-08T09:01:00.000-07:00</published><updated>2009-06-08T09:50:38.121-07:00</updated><title type='text'>Migration to Google Code</title><content type='html'>Today SnakeYAML has successfully migrated from Assembla to &lt;a href="http://code.google.com/p/snakeyaml/"&gt;Google Code&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Thanks to Google for providing Mercurial support. Now Google is used to host the whole project infrastructure:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Project home&lt;/li&gt;&lt;li&gt;source&lt;/li&gt;&lt;li&gt;wiki (documentation)&lt;/li&gt;&lt;li&gt;download&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;span style="font-style: italic;"&gt;Google AppEngine&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;generated project reports&lt;/li&gt;&lt;li&gt;Maven 2 repository&lt;/li&gt;&lt;li&gt;InstantYAML (http://instantyaml.appspot.com/) application&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;The bigest problem was to convert documentation from one wiki markup to another. Fortunately they are not that different.&lt;br /&gt;&lt;br /&gt;At Assembla (due to incredible amount of spam) I had to allow only registered users to create Trac tickets. Now anybody can report a bug or suggest a feature.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-3936826424736282531?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/3936826424736282531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=3936826424736282531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/3936826424736282531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/3936826424736282531'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/06/migration-to-google-code.html' title='Migration to Google Code'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-1890895267889237952</id><published>2009-03-03T07:18:00.000-08:00</published><updated>2009-03-03T07:48:58.689-08:00</updated><title type='text'>Performance, regular expressions and Ragel</title><content type='html'>Recently I got a &lt;a href="http://stackoverflow.com/questions/531920/jyaml-dump-object-without-including-class-name"&gt;note&lt;/a&gt; that &lt;a href="http://trac-hg.assembla.com/snakeyaml/"&gt;SnakeYAML&lt;/a&gt; is slower that JYaml. I have written a small stress &lt;a href="http://trac-hg.assembla.com/snakeyaml/browser/src/test/java/org/yaml/snakeyaml/StressTest.java"&gt;test&lt;/a&gt; to load a &lt;a href="http://trac-hg.assembla.com/snakeyaml/browser/src/test/resources/specification/example2_27.yaml"&gt;document&lt;/a&gt; in a cycle. Indeed, it clearly showed that SnakeYAML performs bad with a big load.&lt;br /&gt;Profiler could help to find the bottleneck - regular expressions. First, they are slow (I am afraid Just-in-Time compiler does not work here). Second, they scale badly, the bigger the load the slower they perform.&lt;br /&gt;Regular expressions are used to support implicit types. Based on the data format SnakeYAML creates an appropriate Java class:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;123&lt;/span&gt; -&gt; Integer&lt;br /&gt;&lt;span style="font-style: italic;"&gt;1.0&lt;/span&gt; -&gt; Float&lt;br /&gt;&lt;span style="font-style: italic;"&gt;false &lt;/span&gt;-&gt; Boolean&lt;br /&gt;&lt;span style="font-style: italic;"&gt;2009-03-25&lt;/span&gt; -&gt; Date&lt;br /&gt;&lt;span style="font-style: italic;"&gt;abc&lt;/span&gt; -&gt; String&lt;br /&gt;and so on.&lt;br /&gt;Of course we may take the JYaml's approach and drop regular expressions. Then all the scalars become Strings. It works but then developers must support all the (weird) formats like:&lt;br /&gt;'&lt;span style="font-style: italic;"&gt;1_000.5000_&lt;/span&gt;' -&gt; 1000.5&lt;br /&gt;&lt;span style="font-style: italic;"&gt;23:59:59&lt;/span&gt; -&gt; int&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Off&lt;/span&gt; -&gt; false&lt;br /&gt;&lt;span style="font-style: italic;"&gt;~&lt;/span&gt; -&gt; null&lt;br /&gt;etc.&lt;br /&gt;Fortunately I came across &lt;a href="http://www.complang.org/ragel/"&gt;Ragel&lt;/a&gt;. I gave it a try. It is cool. It creates an extremely fast implementation.&lt;br /&gt;Regular expressions for implicit types are removed. First, we do not need to compile them when an instance of Yaml is created. Second, we do not match a long list of regular expressions against each and every scalar with an implicit type. As a result  the stress test performs 2-3 times faster! This is impressive.&lt;br /&gt;Of course if a single YAML document is loaded then the performance would not grow that much. This is because SnakeYAML has a number of static initializers for constants. Once the very first &lt;a href="http://trac-hg.assembla.com/snakeyaml/browser/src/main/java/org/yaml/snakeyaml/Yaml.java"&gt;Yaml&lt;/a&gt; instance is created other instances are very chip to create. It should not have any significant influence on the performance.&lt;br /&gt;This changes will be introduced soon in SnakeYAML 1.1.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=""&gt; &lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-1890895267889237952?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/1890895267889237952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=1890895267889237952' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/1890895267889237952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/1890895267889237952'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/03/performance-regular-expressions-and.html' title='Performance, regular expressions and Ragel'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-7474185152923596704</id><published>2009-02-03T04:28:00.000-08:00</published><updated>2009-02-03T04:41:20.257-08:00</updated><title type='text'>InstantYAML is released</title><content type='html'>&lt;a href="http://instantyaml.appspot.com/"&gt;InstantYAML&lt;/a&gt; is released today.&lt;br /&gt;I hope it will help:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;newbies to get easier the YAML concept&lt;/li&gt;&lt;li&gt;developers to come to a common denominator for what events, tokens and nodes are. Unfortunately they deviate significantly in the myriad of current YAML libraries.&lt;/li&gt;&lt;/ul&gt;PyYAML 3.05 is used to parse and emit the document. Once I have time I will update it to the latest version.&lt;br /&gt;&lt;br /&gt;I must say Google AppEngine rocks. Development environment is very good and deployment is incredibly easy. It just took me a while to cope with the proxy...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-7474185152923596704?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/7474185152923596704/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=7474185152923596704' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/7474185152923596704'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/7474185152923596704'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/02/instantyaml-is-released.html' title='InstantYAML is released'/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-792103708733812051</id><published>2009-01-16T15:07:00.000-08:00</published><updated>2009-01-16T15:22:14.061-08:00</updated><title type='text'></title><content type='html'>Finally I got some time to finish all the planned features of SnakeYAML 1.0. Everything I find useful in the existing YAML libraries is implemented.&lt;br /&gt;Special thanks to&lt;br /&gt;&lt;ul&gt;&lt;li&gt;JvYaml. Even though nothing is left it gave a good starting point and I did not have to start from scratch and it was possible to overwrite the code component by component&lt;/li&gt;&lt;li&gt;YamlBeans for ideas how to implement JavaBeans support.&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Version 1.0rc1 is &lt;a href="http://trac-hg.assembla.com/snakeyaml"&gt;released&lt;/a&gt; and if there would be no issues found the final 1.0 will be released soon.&lt;br /&gt;&lt;br /&gt;The critics is welcome!!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-792103708733812051?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/792103708733812051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=792103708733812051' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/792103708733812051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/792103708733812051'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2009/01/finally-i-got-some-time-to-finish-all.html' title=''/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-3983476083256713459</id><published>2008-11-11T03:57:00.000-08:00</published><updated>2008-11-11T04:06:00.653-08:00</updated><title type='text'></title><content type='html'>I have created a space in Assembla to look closely at JvYaml and call it SnakeYAML (http://trac-hg.assembla.com/snakeyaml). The source migrated from CVS to Mercurial. Standard Maven folder structure is applied.&lt;br /&gt;It is very convenient that JvYaml is a direct port of PyYAML. It is so easy to see the Python implementation and compare the deviations. It is even possible to debug two implementations in parallel on 2 computers ! (Synergy is dead useful).&lt;br /&gt;Before the code is changed let us contribute tests. A lot of examples from the http://yaml.org/spec/1.1/ are created. Unfortunately a number of tests fails.&lt;br /&gt;These are some deviation from original Python code:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Reader is dropped (in favor of java.io.Reader) and BOM is not respected. When stream is read the encoding must be known which is not always possible (and it is against the specification)&lt;/li&gt;&lt;li&gt;Scanner implementation is simplified. All the comments are removed. &lt;/li&gt;&lt;li&gt;Python implementation is not followed very closely. For instance a boolean in Python may be True, False and None. But Java implementation is using a primitive instead of the class Boolean and the third state is gone. It causes for example trimming the trailing spaces in the block scalars.&lt;/li&gt;&lt;li&gt;Python module is close to Java package. It helps separate code logically.&lt;/li&gt;&lt;li&gt;no tests are imported from PyYAML&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Let us improve the implementation and try to follow the specification as close as possible.&lt;br /&gt;This is what is done so far:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Java does not have multiple inheritance (which is very good!). The way how multiple inheritance is used in PyYAML is not very correct. Let us follow a reliable recommendation - "use composition over inheritance". Now Reader is an instance variable in Scanner.&lt;/li&gt;&lt;li&gt;Change the public interface and stay closer to PyYAML. Use Iterator instead of List. The java.io.InputStream is used and the encoding is recognized (and ignored) automatically&lt;/li&gt;&lt;li&gt;Rename classes with respect to "Python module" -&gt; "Java package".&lt;/li&gt;&lt;li&gt;Define code formatter which can be imported to Eclipse&lt;/li&gt;&lt;li&gt;Go through ScannerImpl and try to stay as close as possible to PyYAML. A number of issues fixed. The size is almost doubled (~2000 lines), mostly because of the comments in the code.&lt;/li&gt;&lt;li&gt;some tests are imported from PyYAML&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;Because SnakeYAML provides some improvements over existing YAML libraries I can release the library.&lt;br /&gt;Documentation is much worse then it should be. I will try to improve it later.&lt;br /&gt;If somebody needs a reliable YAML parser for Java take SnakeYAML !&lt;br /&gt;SnakeYAML 0.4 is born to this beautiful World...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-3983476083256713459?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/3983476083256713459/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=3983476083256713459' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/3983476083256713459'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/3983476083256713459'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2008/11/i-have-created-space-in-assembla-to.html' title=''/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-6650056330738855471</id><published>2008-10-30T11:12:00.000-07:00</published><updated>2008-10-30T11:19:12.256-07:00</updated><title type='text'></title><content type='html'>I have put YamlBeans 0.9.2 to my project. It works.&lt;br /&gt;To see the internals better I have created a space in Assemla&lt;br /&gt;http://trac-hg.assembla.com/yamlb&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;source code migrated from SVN to Mercurial&lt;/li&gt;&lt;li&gt;use Maven and apply the recommended folder structure&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-style: italic;"&gt;:( Mercurial is not perfect. When a resource is renamed it is not that simple to see the history in Eclipse.)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Because the project does not define a lot of tests I have started contributing tests to cover complete YAML 1.1. Once I have written most of examples from Chapter 2 (http://yaml.org/spec/1.1/) and most types (http://yaml.org/type/index.html) I realized that YamlBeans fails to cope with a lot of them.&lt;br /&gt;The biggest problem is that most of types are not supported. Only strings, sequences and mappings work.&lt;br /&gt;Read from the YamlBeans project page:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: verdana; color: rgb(51, 51, 153);"&gt;The YAML tokenizer, parser, and emitter are based on those from the JvYAML project. They have been heavily refactored, bugs fixed, etc. The rest of the JvYAML project was not used because of its complexity. YamlBeans strives for the simplest possible thing that works, with the goal being to make it easy to use the YAML data format with Java.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Unfortunately, an attempt to agree with the developer on what shall be supported did not lead to a common understanding. Apparently it should be not a big deal for Java projects.&lt;br /&gt;But it creates an inconvenience if data is exchanged between Java and Python. For instance&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: courier new;"&gt;map.put("text", "123")&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;will dump in YamlBeans&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;text: 123&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;instead of (like it is in JvYAML)&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;---&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;text: !!str 123&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As a result PyYAML will assign to 'text' an integer which is not what I would expect.&lt;br /&gt;&lt;br /&gt;Also YamlBeans will parse null, bool, float, int, binary as strings. Which is not always convenient.&lt;br /&gt;&lt;br /&gt;The public interface was significantly changed and I need to learn 'yet another API' to work with YAML.&lt;br /&gt;&lt;br /&gt;I think I shall give JvYAML a try.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-6650056330738855471?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/6650056330738855471/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=6650056330738855471' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/6650056330738855471'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/6650056330738855471'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2008/10/i-have-put-yamlbeans-0.html' title=''/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4336104534924908200.post-2543136980950879787</id><published>2008-10-30T09:18:00.000-07:00</published><updated>2008-10-30T09:24:23.295-07:00</updated><title type='text'></title><content type='html'>I need to deliver a RESTful service in Java. Restlet seems to be a good way to go. What should be the data format ? XML alone does not look very user friendly. Let me try to provide XML, YAML and JSON.&lt;br /&gt;XML and JSON are well supported in Java. But the YAML support leaves much to be desired...&lt;br /&gt;There are 5 open source implementations I could find:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;yaml4j (http://yaml4j.sourceforge.net/)&lt;/li&gt;&lt;li&gt;JYaml (http://jyaml.sourceforge.net/index.html)&lt;/li&gt;&lt;li&gt;JvYAML (https://jvyaml.dev.java.net/)&lt;/li&gt;&lt;li&gt;YamlBeans (http://yamlbeans.sourceforge.net/)&lt;/li&gt;&lt;li&gt;JvYAMLb (http://code.google.com/p/jvyamlb/)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;First three look dead. But JvYAML is exceptional because it is a port from PyYAML. In case of a question it is always possible to consult Python implementation.&lt;br /&gt;YamlBeans is a new kid on the block and it is based on JvYAML. JvYAMLb has a dependency on JRuby which makes it impossible to use it in my projects.&lt;br /&gt;So we are down to 2 libraries: JvYAML and YamlBeans.&lt;br /&gt;&lt;br /&gt;JvYAML pros:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;supports most of YAML 1.1&lt;/li&gt;&lt;li&gt;based on well supported project&lt;/li&gt;&lt;li&gt;the developer has a blog (http://ola-bini.blogspot.com/2006/09/announcing-jvyaml-021.html)&lt;/li&gt;&lt;/ul&gt;JvYAML cons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;all the issues stay open (https://jvyaml.dev.java.net/issues/buglist.cgi?target_milestone=milestone%201&amp;amp;issue_status=UNCONFIRMED&amp;amp;issue_status=NEW&amp;amp;issue_status=STARTED&amp;amp;issue_status=REOPENED)&lt;/li&gt;&lt;li&gt;anchors and aliases are dumped even when this is not needed, which reduces readability&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;YamlBeans prons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;very good support for JavaBeans&lt;/li&gt;&lt;li&gt;good output&lt;/li&gt;&lt;/ul&gt;YamlBeans cons:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;reduced support for YAML 1.1 (most of types are not supported)&lt;/li&gt;&lt;li&gt;code significantly deviates from PyYAML&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;YamlBeans seems to be an easier way to go. Let's give it a try.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4336104534924908200-2543136980950879787?l=vomos.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vomos.blogspot.com/feeds/2543136980950879787/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4336104534924908200&amp;postID=2543136980950879787' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/2543136980950879787'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4336104534924908200/posts/default/2543136980950879787'/><link rel='alternate' type='text/html' href='http://vomos.blogspot.com/2008/10/i-need-to-deliver-restful-service-in.html' title=''/><author><name>Andrey Somov</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
