[ 
https://issues.apache.org/jira/browse/CAMEL-23381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18077782#comment-18077782
 ] 

Claus Ibsen commented on CAMEL-23381:
-------------------------------------

Using parameter with comma separation just makes the syntax and parsing harder 
as comma are used in xpath/jsonpath as well.

Something ala
 * {{{}$\{int:xpath(//food/price){}}}}

Where we can look at making ${resultType:command...} supported so you can do 
this in general. And then have this for a set of known result types (not 
everything)

However this complicates 3rd party tooling as they dont understand that syntax. 

 

 

> simple language - Set the resulttype directly on xpath and jsonpath functions
> -----------------------------------------------------------------------------
>
>                 Key: CAMEL-23381
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23381
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Raymond
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.x
>
>
> 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)

Reply via email to