Transforming from Java to JSON

Camel's JSON Component is used when you need to convert your JSON data back and forth from Java. It provides a Camel Data Format that, without any requirement for an annotated Java class, allows you to marshal (Java to JSON) or unmarshal (JSON to Java) your data.

There is only one step to using Camel JSON to marshal and unmarshal XML data. Within your Camel route, insert the marshal (Java to JSON), or unmarshal (JSON to Java) statement, and configure it to use the JSON Data Format.

This recipe will show you how to use the camel-xstream library to convert from Java to JSON, and back.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.transformation.json package. The Spring XML files are located ...

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.