JSONPath expression for checking string in Apache Camel XML


Let's say I have a simple json file such as the following

{ "log": { "host": "blah", "severity": "INFO", "system": "1" } }

I'm using Apache Camel, and it's Spring XML to process and route the json file. My routing code looks something like this:

<route> <from uri="file:/TESTFOLDER/input"/> <choice> <when> <jsonpath>$.log?(@.severity == 'WARNING')</jsonpath> <to uri="smtp://(smtpinfo...not important)"/> </when> <otherwise> <to uri="file:/TESTFOLDER/output"/> </otherwise> </choice> </route>

The part that I'm really confused about is the JSONPath expression. The expression I have above isn't even syntactically correct, because its hard to find examples for the case where you aren't trying to sort through a list of elements. My goal is to only send an email if the severity of the log is 'WARNING' but I can't come up with the expression.


This worked for me using Camel 2.13.1 (I checked for INFO as your JSON example has this severity; you may change this according to your needs):

<jsonpath>$..log[?(@.severity == 'INFO')]</jsonpath>

Note the .. and the []. However, using a single dot . at the beginning of the search path failed:

<jsonpath>$.log[?(@.severity == 'INFO')]</jsonpath>

The error messages said:

java.lang.IllegalArgumentException: Invalid container object

This may be a bug.

According to the JSON Path <a href="http://goessner.net/articles/JsonPath/" rel="nofollow">doc</a>, .. stands for "recursive descent". This may not meet your requirements. However, as a single dot . didn't work, this was the only possible work around I figured out. Otherwise, you may rise a bug ticket.


  • PHP code works on Chrome, but not on Firefox or IE
  • RBAC - Limit access for one service account
  • Compare directory name to string
  • too much recursion error in jquery
  • unable to run Htmlunit application using Maven dependency
  • How to find parentNode from childNode in a JSON structure using jsonPath or an alternative?
  • zend smtp mail crashes after 100+ mails
  • Image in Email Subject using PHP
  • How to configure Monolog to send errors via SwiftMailer to alternate mailer in Symfony2
  • Django Rest Framework: getting lists from query_params without request.getlist
  • Installing a python package in a desired folder
  • Simple command-line app I/O in Dart
  • SmtpClient sends email to junk
  • DIV instruction jumping to random location?
  • calculate gradient output for Theta update rule
  • Diff between two dataframes in pandas
  • Access variable of ScriptContext using Nashorn JavaScript Engine (Java 8)
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • Moving Android View and preventing onDraw to be called over and over again
  • System.InvalidCastException: Specified cast is not valid
  • xtable package: Skipping some rows in the output
  • C: Incompatible pointer type initializing
  • Problem while Building a Setup Project for a windows Service?
  • How to attach a node.js readable stream to a Sendgrid email?
  • Functions in global context
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Why value captured by reference in lambda is broken? [duplicate]
  • output of program is not same as passed argument
  • Modifying destination and filename of gulp-svg-sprite
  • Deserializing XML into class C#
  • How to handle AllServersUnavailable Exception
  • what is the difference between the asp.net mvc application and asp.net web application
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • SetUp method failed while running tests from teamcity
  • Matrix multiplication with MKL
  • python draw pie shapes with colour filled
  • Binding checkboxes to object values in AngularJs
  • How to Embed XSL into XML