Child pages
  • JSonPath
Skip to end of metadata
Go to start of metadata


Available as of Camel 2.13

Camel supports JSonPath to allow using Expression or Predicate on json messages.

Using XML configuration

If you prefer to configure your routes in your Spring XML file then you can use JSonPath expressions as follows


See the JSonPath project page for further examples.

Suppress exceptions

Available as of Camel 2.16

By default jsonpath will throw an exception if the json payload does not have a valid path accordingly to the configured jsonpath expression. In some use-cases you may want to ignore this in case the json payload contains optional data. Therefore you can set the option suppressExceptions to true to ignore this as shown:

And in XML DSL:


This option is also available on the @JsonPath annotation.

Inline Simple expressions

Available as of Camel 2.18

Its now possible to inlined Simple language expressions in the JSonPath expression using the simple syntax ${xxx}. An example is shown below:

In this example the Simple expression inlined is the headers with the cheap and average values to be used. 

You can turn off support for inlined simple expression by setting the option allowSimple to false as shown:







JSonPath injection

You can use Bean Integration to invoke a method on a bean and use various languages such as JSonPath to extract a value from the message and bind it to a method parameter.

For example

Encoding Detection

Since Camel version 2.16, the encoding of the JSON document is detected automatically, if the document is encoded in unicode  (UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE ) as specified in  RFC-4627. If the encoding is a non-unicode encoding, you can either make sure that you enter the document in String format to the JSONPath component or you can specify the encoding in the header "CamelJsonPathJsonEncoding" (JsonpathConstants.HEADER_JSON_ENCODING).


To use JSonPath in your camel routes you need to add the a dependency on camel-jsonpath which implements the JSonPath language.

If you use maven you could just add the following to your pom.xml, substituting the version number for the latest & greatest release (see the download page for the latest versions).

  • No labels