How to extract substring IN JSON PATH using CAMEL

1.7k Views Asked by At

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 !

0

There are 0 best solutions below