我如何遍历 json 和 post camelcontext 中的每个索引
How do I Loop over json and post every index in camelcontext
假设我有以下 CamelContext:
<camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
<route id="upsertItem">
<from uri="cxf:bean:someEndpoint" />
<process ref="someTransformer" />
<log message="$someJson"/>
</route>
</camelContext>
$someJson 包含以下 json:
{
"0":{
"title":"hello world",
"description":"a greeting to the world"
},
"1":{
"title":"goodbye world",
"description":"a goodbye to the world"
}
//might have more indexes
}
我想编辑我的 CamelContext 以便它可以 post 每个索引到端点。问题是我找不到如何遍历 JSON.
所以我想要这样的东西:
<loop src="${someJson[index]}">
<to uri="http://bookstore/api/books"/>
</loop>
可以通过拆分原始消息来完成
<split>
<jsonpath>$[*]</jsonpath>
<log message="${body}"/>
</split>
假设我有以下 CamelContext:
<camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
<route id="upsertItem">
<from uri="cxf:bean:someEndpoint" />
<process ref="someTransformer" />
<log message="$someJson"/>
</route>
</camelContext>
$someJson 包含以下 json:
{
"0":{
"title":"hello world",
"description":"a greeting to the world"
},
"1":{
"title":"goodbye world",
"description":"a goodbye to the world"
}
//might have more indexes
}
我想编辑我的 CamelContext 以便它可以 post 每个索引到端点。问题是我找不到如何遍历 JSON.
所以我想要这样的东西:
<loop src="${someJson[index]}">
<to uri="http://bookstore/api/books"/>
</loop>
可以通过拆分原始消息来完成
<split>
<jsonpath>$[*]</jsonpath>
<log message="${body}"/>
</split>