From inside a camel route we can retrieve the value by using its index easily.
To retrieve an item from a list by using index, use below code which will reads the list object in the exchange body and retrieves the value in position 2.
To retrieve an item from a map having String as key, use below code:
Here in the above example the key used is foo. Suppose my key contains spaces, like foo bar. In those cases you needs to enclose those keys with quotes.
In case there is no keyword foo in the map, code will throw NullPointerException. In those cases use null safe operator.
Camel also provides a keyword last to retrieve the last item of the collection.