XML to JSON

While working on Jettison, I often have need to convert XML to JSON. Here’s a simple method that uses XStream and Jettison to do this conversion. import java.io.StringReader; import java.io.StringWriter; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.io.copy.HierarchicalStreamCopier; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import com.thoughtworks.xstream.io.xml.XppReader; public class Test { public static void main(String[] args) throws Exception { String xml =… Continue reading XML to JSON

XStream and Spring OXM (Object/XML Mapping framework)

It all started when I tried to find a solution for customizing an XStream instance for my ActiveMQ XStream message transformer that would be better than currently used (extending a base transformer and providing a custom factory method that will do things like alias, converter, annotation, etc. settings). I wanted an easy solution to configure… Continue reading XStream and Spring OXM (Object/XML Mapping framework)