There maybe an instance where you are already working with xml within an existing webservice and a client is demanding a lighter weight format JSON to be consumed by a REST client. JSON is an easy to read, write and parse format by humans and machines. This example will show how convert xml to from json using Xstream. XStream is a java library with a primary purpose to convert Java Objects into XML and back but was designed with a plugable architecture to provide alternative formats. XStream currently is shipped with JsonHierarchicalStreamDriver which will require a new maven dependency in your project.
Setup
Defining a java object and displaying a pretty print json and xml used in the snippets below.