My Camel route is calling a REST service, which returns a JSON string. Problem is that the JSON is not an object but an array of objects, i.e.:
[
{ object_1 },
{ object_2 }
]
First, I want to figure out if this array is empty, as an expression in a choice-when statement:
.choice()
.when( <array-is-empty-expression> )
...
.otherwise()
...
As a solution I used an expression .when("${body} == '[ ]'") which works fine but it doesn't give me the flexibility to find out how many elements there are in the array (well, just that there are 0 or more than 0). So I would really like something like .when("${body expression} == 0").
Secondly, I want to have an expression that assigns a property of, for example, the second object from the JSON array, to set a header property. For example, .header("To", expression).
Can anyone help me with these expressions?