[
https://issues.apache.org/jira/browse/CAMEL-23381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077269#comment-18077269
]
Claus Ibsen commented on CAMEL-23381:
-------------------------------------
yeah when you inline functions then you may want a more elegant and general way
that is easy to type and understand. Adding it as a parameter is per function
and it also makes things like chaing command harder as it rely more on the
idiom of 1 parameter.
> simple language - Set the resulttype directly on xpath and jsonpath
> -------------------------------------------------------------------
>
> Key: CAMEL-23381
> URL: https://issues.apache.org/jira/browse/CAMEL-23381
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Reporter: Raymond
> Priority: Minor
>
> By default jsonpath and xpath return an object:
> {{}}
> {code:java}
> jsonpath(exp)
> jsonpath(input,exp)
> xpath(exp)
> xpath(input,exp){code}
> Mostly you want to explicitly get the type (string, int, boolean). Since
> 4.18.x this has become a bit more flexible, and developers can do something
> like this:
> {code:java}
> $price1 := ${xpath(//food[name='food1']/price/text())} ~> ${convertTo(int)};
> {code}
> It would be however convenient to set the resultType directly on the function:
> {code:java}
> jsonpath(exp, resultType)
> jsonpath(input,exp, resultType)
> xpath(exp, resultType)
> xpath(input,exp, resultType)
> {code}
> {{Setting the resultType is in aligment with the rest of the Simple language.
> }}
> {{Sidenote:}}
> {{{}I also saw some other ways to define to type in other languages
> like:{}}}{{{}{}}}
> * {{int:${xpath(//food/price)}}}
> * {{${xpath(//food/price).toInteger()}}}
> * {{${xpath(...) as int}}}
> One of the above maybe a bit more elegant, but is of course not the standard
> syntax until now.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)