Hi I would like to use a header value from my camel exchange as a filter condition within my JsonPath expression.
Somethink like this:
.setBody().jsonpath("$.person[?(@.role=='${headers.role}')]")
The simple expression will not be resolved this way.
How can I get this done with Apache Camel?
I discovered one way to get it done with a processor component and some Java Code:
String jsonpathFilter = SimpleLanguage.simple(
"$.person[?(@.role=='${headers.role}')]").evaluate(exchange, String.class);
String result = new JsonPathExpression(jsonpathFilter).evaluate(exchange, String.class);
exchange.getIn().setBody(result);
But I'm not so happy with this solution. So if you know any better way, please let me know.