Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 21. JSonPath
Overview 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The JSonPath language provides a convenient syntax for extracting portions of a JSon message. The syntax of JSon is similar to XPath, but it is used to extract JSon objects from a JSon message, instead of acting on XML. The
jsonpath
DSL command can be used either as an expression or as a predicate (where an empty result gets interpreted as boolean false
).
Adding the JSonPath package 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
To use JSonPath in your Camel routes, you need to add a dependency on
camel-jsonpath
to your project, as follows:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jsonpath</artifactId> <version>${camel-version}</version> </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jsonpath</artifactId>
<version>${camel-version}</version>
</dependency>
Java example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The following Java example shows how to use the
jsonpath()
DSL command to select items in a certain price range:
If the JSonPath query returns an empty set, the result is interpreted as
false
. In this way, you can use a JSonPath query as a predicate.
XML example 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
The following XML example shows how to use the
jsonpath
DSL element to define predicates in a route:
Suppress Exceptions 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
JSonPath will throw an exception if the path configured by the
jsonpath
expression is not found. The exception can be ignored by setting the SuppressExceptions
option to true. For example, in the code below, adding the true option as part of the jsonpath
parameters:
In XML DSL use the following syntax:
JSonPath injection 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
When using bean integration to invoke a bean method, you can use JSonPath to extract a value from the message and bind it to a method parameter. For example:
Reference 링크 복사링크가 클립보드에 복사되었습니다!
링크 복사링크가 클립보드에 복사되었습니다!
For more details about JSonPath, see the JSonPath project page.