|
|
| Article: |
An Introduction to JSON
|
| Subject: |
Simpler solution: produce JSON with XStream |
| Date: |
2007-02-28 03:24:22 |
| From: |
joakim.sandstrom |
|
|
|
It's much more easy to produce JSON output with XStream, just in two lines:
XStream stream = new XStream(new JsonHierarchicalStreamDriver());
String json = stream.toXML(addressBook);
Note that XStream is mainly used to convert Objects into XML and vice versa, that's why the method is named toXML, but one may also use the marshal method.
/ Joakim |
|