Show Table of Contents
Chapter 86. Jolt
JOLT Component
Available as of Camel 2.16
The Jolt component allows you to process a JSON messages using an JOLT specification. This can be ideal when doing JSON to JSON transformation.
Maven users will need to add the following dependency to their
pom.xml for this component:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jolt</artifactId>
<version>2.17.0.redhat-630187</version>
<!-- use the same version as your Camel core version -->
</dependency>URI format
jolt:specName[?options]
Where
specName is the classpath-local URI of the specification to invoke; or the complete URL of the remote specification (eg: file://folder/myfile.json).
You can append query options to the URI in the following format,
?option=value&option=value&...
Options
|
Option
|
Default
|
Description
|
|---|---|---|
contentCache
|
true
|
Cache for the resource content when it is loaded. Note : as of Camel 2.9 cached resource content can be cleared via JMX using the endpoint's
clearContentCache operation.
|
outputType
|
Hydrated
|
Sets the output of the transformation to Hydrated as List or Maps, or JsonString as a String object containing the JSON.
|
inputType
|
Hydrated
|
Sets the input of the transformation to Hydrated as List or Maps, or JsonString as a String object containing the JSON.
|
transformDsl
|
Chainr
|
The transform DSL to use for loading the provided specification. Available values Chainr, Shiftr, Defaultr, Removr and Sortr.
|
Dynamic specification
Camel provides a header by which you can define a different resource location for a specification. If this header is set then Camel uses this over the endpoint configured resource. This allows you to provide a dynamic specification at runtime.
|
Header
|
Type
|
Description
|
|---|---|---|
|
CamelJoltResourceUri
|
String
|
A URI for the specification resource to use instead of the endpoint configured.
|
Samples
For example you could use something like
from("activemq:My.Queue").
to("jolt:com/acme/MyResponse.json");
And a file based resource:
from("activemq:My.Queue").
to("jolt:file://myfolder/MyResponse.json?contentCache=true").
to("activemq:Another.Queue");
You can also specify what specification the component should use dynamically via a header, so for example:
from("direct:in").
setHeader("CamelJoltResourceUri").constant("path/to/my/spec.json").
to("jolt:dummy");
Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.