A side note.
A new component is coming in Camel 2.10, that can map directly between XML <-> JSon, camel-xmljson
Currently its in development, and we dont have any documentation yet. The source code is here:
The json data format uses XStream, that uses Jettison. So I guess the XStream project has better documentation:
The Camel XML DSL has a data format that have options for configuring XStream. I wonder if any of those can help to configure it to map JSon to XML without any POJOs
I was able to create a Bean which wrapped the Jettison library and use it as a Transform. That worked with the exception that it does not handle JSON arrays the way I expected. I built the camel-xmljson project as a Bundle and deployed in ServiceMix4.4.1, but I need to know how to include the dependencies. I get the following error:
karaf@root> bundles:start 188
I am relatively new to ServiceMix and would like to know the best way to include the dependencies that are not in ServiceMix (i.e. json-lib.jar). I did notice there is also a patch for Camel that includes the camel-xmljson. Would it be a better option to go about applying the diff to camel 2.8.4 release?
Basically FUSE ESB/Servicemix is also an OSGi container, so you can install json-lib.jar as a bundle in FUSE ESB before you install camel-xmljson bundle.
Typically you would install the camel-xmljson ServiceMix feature. A feature is a group of bundles, other features and configuration entries. By installing the feature, ServiceMix will take care of installing whatever is needed to make the component work.
We have provided a camel-xmljson feature which you can install using the following command:
Previously, you should have added the features repository by using the following command:
(provided that your SMX instance is configured to access public SNAPSHOT repositories, which it is if you're running the default config)
However, I do not recommend doing this at this point, as it will drag along camel-core 2.10, camel-spring 2.10, etc. etc. etc. So an entire Camel 2.10 runtime will be installed along with any dependencies. This could mess you things for you. Instead, you probably want to make the component work with whatever version of Camel you're on.
So instead, run the following sequence of commands to install the dependencies one-by-one:
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-beanutils/1.8.3_1
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.oro/2.0.8_6
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ezmorph/1.0.6_1-SNAPSHOT
install -s mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.json-lib/2.4_1-SNAPSHOT
install -s mvn:org.apache.camel/camel-xmljson/2.10-SNAPSHOT
And you should be good to go! (no need to build camel-xmljson locally even... as the SNAPSHOT is already available in the public Maven repos!)
Hope that helps.