How to extract substring IN JSON PATH using CAMEL

微笑、不失礼 提交于 2019-12-11 09:59:18

问题


I am trying to configure my routes based on the substring of value from an attribute. For example,

I have this Json Attribute:

{
"carColor": "Red/hatchback"
}

There are other possibilities such as "Blue/Sedan" and "Black/SUV" etc. I would like to extract the colors only. Meaning I would like to extract the colors before the "/" sign like "Red", "Blue, "Black" etc.

This is what I have at the moment:

<when>
    <jsonpath>$.root[?(@.carColor == 'Red')]</jsonpath>
    <to uri="redCar"/>
    </when>

I know it is wrong because hte whole string contains "Red/Hatchback" but i have no idea how to implement the 'contain' feature in this case. Any help will be much appreciated. Thanks !

来源:https://stackoverflow.com/questions/41715654/how-to-extract-substring-in-json-path-using-camel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!