3

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 !

Kenster
  • 23,465
  • 21
  • 80
  • 106
purplewind
  • 331
  • 10
  • 26
  • You can try the `=~` which is the regular expression matching. Or you can extract the json path first, and then do a Camel simple predicate to check if the header starts with or contains which can be easier to do than a regular expression – Claus Ibsen Jan 19 '17 at 10:12
  • JSonPath documentation is at: https://github.com/jayway/JsonPath – Claus Ibsen Jan 19 '17 at 10:12

0 Answers0