Thursday, October 30, 2008

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.
XML and JSON are well supported in Java. But the YAML support leaves much to be desired...
There are 5 open source implementations I could find:
  • yaml4j (http://yaml4j.sourceforge.net/)
  • JYaml (http://jyaml.sourceforge.net/index.html)
  • JvYAML (https://jvyaml.dev.java.net/)
  • YamlBeans (http://yamlbeans.sourceforge.net/)
  • JvYAMLb (http://code.google.com/p/jvyamlb/)

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.
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.
So we are down to 2 libraries: JvYAML and YamlBeans.

JvYAML pros:
  • supports most of YAML 1.1
  • based on well supported project
  • the developer has a blog (http://ola-bini.blogspot.com/2006/09/announcing-jvyaml-021.html)
JvYAML cons:
  • all the issues stay open (https://jvyaml.dev.java.net/issues/buglist.cgi?target_milestone=milestone%201&issue_status=UNCONFIRMED&issue_status=NEW&issue_status=STARTED&issue_status=REOPENED)
  • anchors and aliases are dumped even when this is not needed, which reduces readability

YamlBeans prons:
  • very good support for JavaBeans
  • good output
YamlBeans cons:
  • reduced support for YAML 1.1 (most of types are not supported)
  • code significantly deviates from PyYAML


YamlBeans seems to be an easier way to go. Let's give it a try.

0 comments: