2007年1月17日 星期三

Java and JSON

引自 ONJava.com 的文章,讓 Java POJO 能直接 serialize 成 JSON Format,或由 JSON Format unserialize 回 Java POJO ,透過 XStream 的 toXML 和 fromXML 相當容易及實用。

##CONTINUE##

Java and JSON
from ONJava.com by webmaster@oreillynet.com (Dejan Bosanac)

It seems that JSON vs. XML debate was one of the hot topics for this winter. Again, I think that “vs.” part is sufficient and that both XML and JSON should have their place in overall technology landscape. One of the obvious JSON advantages is that it can be directly evaluated in JavaScript. And for the Ajax-world we live in, it is not a small thing.

For one project, I started looking for a library that would enable me easy transformations between Java and JSON data. JSON in Java looks nice, but what I really want is a more automated and configurable library like those we have for XML processing. My first thought was XStream since I like its simple API, extensible architecture, powerful converters and support for annotations. After first check I found that from version 1.2 on there is a partial support for JSON (which was logical thing to expect). So, currently you can serialize your Java objects to JSON format."
張貼留言