デフォルトでは、設定された jsonpath 式に従って json ペイロードに有効なパスがない場合には、jsonpath は例外を出力します。ユースケースによっては、json ペイロードにオプションのデータが含まれている時にはこれを無視する場合があります。したがって、以下に示すように、オプション suppressExceptions を true に設定して、これを無視できます。
from("direct:start")
.choice()
// use true to suppress exceptions
.when().jsonpath("person.middlename", true)
.to("mock:middle")
.otherwise()
.to("mock:other");
from("direct:start")
.choice()
// use true to suppress exceptions
.when().jsonpath("person.middlename", true)
.to("mock:middle")
.otherwise()
.to("mock:other");
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
<route>
<from uri="direct:start"/>
<choice>
<when>
<jsonpath suppressExceptions="true">person.middlename</jsonpath>
<to uri="mock:middle"/>
</when>
<otherwise>
<to uri="mock:other"/>
</otherwise>
</choice>
</route>
<route>
<from uri="direct:start"/>
<choice>
<when>
<jsonpath suppressExceptions="true">person.middlename</jsonpath>
<to uri="mock:middle"/>
</when>
<otherwise>
<to uri="mock:other"/>
</otherwise>
</choice>
</route>
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow