Hi Alex,
Alex Quezada wrote:
> Hello,
>
> Since I need to pass my objects through JAXB annotations before
> turning into JSON, I'm first marshalling to XML. Now I need to go
> from an XML string to a JSON string. I'm pretty sure that's possible,
> since I found an example to do the opposite (JSON string to XML
> string), but no luck so far. Any ideas?
String toJSON(String xml) {
StringWriter writer = new StringWriter();
new HierarchicalStreamCopier().copy(
new DomReader(xml), new JsonWriter(writer));
return writer.toString();
}
- Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email