Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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:

Code Block
from("direct:start")
  .choice()
    .when().jsonpath("$.store.book[?(@.price < ${header.cheap})]")
      .to("mock:cheap")
    .when().jsonpath("$.store.book[?(@.price < ${header.average})]")
      .to("mock:average")
    .otherwise()
      .to("mock:expensive");

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


Code Block
xml
xml
    <route>
      <from uri="direct:start"/>
      <choice>
        <when>
          <jsonpath>$.store.book[?(@.price < ${header.cheap})]</jsonpath>
          <to uri="mock:cheap"/>
        </when>
        <when>
          <jsonpath>$.store.book[?(@.price < ${header.average})]</jsonpath>
          <to uri="mock:average"/>
        </when>
        <otherwise>
          <to uri="mock:expensive"/>
        </otherwise>
      </choice>
    </route>


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.

...