Parsing JSON within the Camel Velocity component template?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Parsing JSON within the Camel Velocity component template?

Gerald Kallas - mailbox.org
Dear community,

I've following snippet ..

<setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
<to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />

The body comes from a jsonpath expression earlier. I've just stripped it to the essentials.

Is it possible to access inside a Camel Velocity component template to the attribute values for name and surname?

Many thanks for any response in advance.

Best
- Gerald
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Alex Dettinger
Hi Gerald,

  The example below shows how to use a pojo from a velocity context:

https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java

  So, chances are that you just need to set the body to a pojo offering a
getName() method and then use it from the velocity context with $body.name.
This is not something I've tested, but looks worth a try.

Alex

On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <[hidden email]> wrote:

> Dear community,
>
> I've following snippet ..
>
>
> <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
>
> The body comes from a jsonpath expression earlier. I've just stripped it
> to the essentials.
>
> Is it possible to access inside a Camel Velocity component template to the
> attribute values for name and surname?
>
> Many thanks for any response in advance.
>
> Best
> - Gerald
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Mantas Gridinas
Why not use unmarshall EIP before passing the body to velocity
template? Then, as per the velocity component, you would access your
body via $body variable.

On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <[hidden email]> wrote:

>
> Hi Gerald,
>
>   The example below shows how to use a pojo from a velocity context:
>
> https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
>
>   So, chances are that you just need to set the body to a pojo offering a
> getName() method and then use it from the velocity context with $body.name.
> This is not something I've tested, but looks worth a try.
>
> Alex
>
> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <[hidden email]> wrote:
>
> > Dear community,
> >
> > I've following snippet ..
> >
> >
> > <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> > <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
> >
> > The body comes from a jsonpath expression earlier. I've just stripped it
> > to the essentials.
> >
> > Is it possible to access inside a Camel Velocity component template to the
> > attribute values for name and surname?
> >
> > Many thanks for any response in advance.
> >
> > Best
> > - Gerald
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Gerald Kallas - mailbox.org
Tx for the reply. I tried this already, but the question still remains how to access the single attributes of the JSON tree inside Velocity component.

Best
- Gerald

Am 07.01.2020 um 12:45 schrieb Mantas Gridinas <[hidden email]>:

>
> Why not use unmarshall EIP before passing the body to velocity
> template? Then, as per the velocity component, you would access your
> body via $body variable.
>
>> On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <[hidden email]> wrote:
>>
>> Hi Gerald,
>>
>>  The example below shows how to use a pojo from a velocity context:
>>
>> https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
>>
>>  So, chances are that you just need to set the body to a pojo offering a
>> getName() method and then use it from the velocity context with $body.name.
>> This is not something I've tested, but looks worth a try.
>>
>> Alex
>>
>>> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <[hidden email]> wrote:
>>>
>>> Dear community,
>>>
>>> I've following snippet ..
>>>
>>>
>>> <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
>>> <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
>>>
>>> The body comes from a jsonpath expression earlier. I've just stripped it
>>> to the essentials.
>>>
>>> Is it possible to access inside a Camel Velocity component template to the
>>> attribute values for name and surname?
>>>
>>> Many thanks for any response in advance.
>>>
>>> Best
>>> - Gerald

Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Mantas Gridinas
Might want to read up on Velocity user guide, then
https://velocity.apache.org/engine/2.1/user-guide.html#property-lookup-rules

On Tue, Jan 7, 2020 at 1:48 PM Gerald Kallas - mailbox.org
<[hidden email]> wrote:

>
> Tx for the reply. I tried this already, but the question still remains how to access the single attributes of the JSON tree inside Velocity component.
>
> Best
> - Gerald
>
> Am 07.01.2020 um 12:45 schrieb Mantas Gridinas <[hidden email]>:
> >
> > Why not use unmarshall EIP before passing the body to velocity
> > template? Then, as per the velocity component, you would access your
> > body via $body variable.
> >
> >> On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <[hidden email]> wrote:
> >>
> >> Hi Gerald,
> >>
> >>  The example below shows how to use a pojo from a velocity context:
> >>
> >> https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
> >>
> >>  So, chances are that you just need to set the body to a pojo offering a
> >> getName() method and then use it from the velocity context with $body.name.
> >> This is not something I've tested, but looks worth a try.
> >>
> >> Alex
> >>
> >>> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <[hidden email]> wrote:
> >>>
> >>> Dear community,
> >>>
> >>> I've following snippet ..
> >>>
> >>>
> >>> <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> >>> <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
> >>>
> >>> The body comes from a jsonpath expression earlier. I've just stripped it
> >>> to the essentials.
> >>>
> >>> Is it possible to access inside a Camel Velocity component template to the
> >>> attribute values for name and surname?
> >>>
> >>> Many thanks for any response in advance.
> >>>
> >>> Best
> >>> - Gerald
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Gerald Kallas - mailbox.org
Tx, Mantas.

Neverthless that still means to transfer the JSON into a (pre-defined) POJO in front of Velocity processing. I wonder if there is any other way to access a JSON object directly from the Velocity engine.

Best
- Gerald

> Mantas Gridinas <[hidden email]> hat am 7. Januar 2020 um 12:51 geschrieben:
>
>
> Might want to read up on Velocity user guide, then
> https://velocity.apache.org/engine/2.1/user-guide.html#property-lookup-rules
>
> On Tue, Jan 7, 2020 at 1:48 PM Gerald Kallas - mailbox.org
> <[hidden email]> wrote:
> >
> > Tx for the reply. I tried this already, but the question still remains how to access the single attributes of the JSON tree inside Velocity component.
> >
> > Best
> > - Gerald
> >
> > Am 07.01.2020 um 12:45 schrieb Mantas Gridinas <[hidden email]>:
> > >
> > > Why not use unmarshall EIP before passing the body to velocity
> > > template? Then, as per the velocity component, you would access your
> > > body via $body variable.
> > >
> > >> On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <[hidden email]> wrote:
> > >>
> > >> Hi Gerald,
> > >>
> > >>  The example below shows how to use a pojo from a velocity context:
> > >>
> > >> https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
> > >>
> > >>  So, chances are that you just need to set the body to a pojo offering a
> > >> getName() method and then use it from the velocity context with $body.name.
> > >> This is not something I've tested, but looks worth a try.
> > >>
> > >> Alex
> > >>
> > >>> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <[hidden email]> wrote:
> > >>>
> > >>> Dear community,
> > >>>
> > >>> I've following snippet ..
> > >>>
> > >>>
> > >>> <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> > >>> <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
> > >>>
> > >>> The body comes from a jsonpath expression earlier. I've just stripped it
> > >>> to the essentials.
> > >>>
> > >>> Is it possible to access inside a Camel Velocity component template to the
> > >>> attribute values for name and surname?
> > >>>
> > >>> Many thanks for any response in advance.
> > >>>
> > >>> Best
> > >>> - Gerald
> >
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Mantas Gridinas
Not necessarily. Unmarshal EIP can be configured to unmarshal into a map.
Check out https://camel.apache.org/manual/latest/json.html as well as the
signature of DataFormatClause#json

On Tue, Jan 7, 2020, 15:09 Gerald Kallas <[hidden email]> wrote:

> Tx, Mantas.
>
> Neverthless that still means to transfer the JSON into a (pre-defined)
> POJO in front of Velocity processing. I wonder if there is any other way to
> access a JSON object directly from the Velocity engine.
>
> Best
> - Gerald
>
> > Mantas Gridinas <[hidden email]> hat am 7. Januar 2020 um 12:51
> geschrieben:
> >
> >
> > Might want to read up on Velocity user guide, then
> >
> https://velocity.apache.org/engine/2.1/user-guide.html#property-lookup-rules
> >
> > On Tue, Jan 7, 2020 at 1:48 PM Gerald Kallas - mailbox.org
> > <[hidden email]> wrote:
> > >
> > > Tx for the reply. I tried this already, but the question still remains
> how to access the single attributes of the JSON tree inside Velocity
> component.
> > >
> > > Best
> > > - Gerald
> > >
> > > Am 07.01.2020 um 12:45 schrieb Mantas Gridinas <[hidden email]>:
> > > >
> > > > Why not use unmarshall EIP before passing the body to velocity
> > > > template? Then, as per the velocity component, you would access your
> > > > body via $body variable.
> > > >
> > > >> On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <
> [hidden email]> wrote:
> > > >>
> > > >> Hi Gerald,
> > > >>
> > > >>  The example below shows how to use a pojo from a velocity context:
> > > >>
> > > >>
> https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
> > > >>
> > > >>  So, chances are that you just need to set the body to a pojo
> offering a
> > > >> getName() method and then use it from the velocity context with $
> body.name.
> > > >> This is not something I've tested, but looks worth a try.
> > > >>
> > > >> Alex
> > > >>
> > > >>> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <
> [hidden email]> wrote:
> > > >>>
> > > >>> Dear community,
> > > >>>
> > > >>> I've following snippet ..
> > > >>>
> > > >>>
> > > >>>
> <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> > > >>> <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
> > > >>>
> > > >>> The body comes from a jsonpath expression earlier. I've just
> stripped it
> > > >>> to the essentials.
> > > >>>
> > > >>> Is it possible to access inside a Camel Velocity component
> template to the
> > > >>> attribute values for name and surname?
> > > >>>
> > > >>> Many thanks for any response in advance.
> > > >>>
> > > >>> Best
> > > >>> - Gerald
> > >
>
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Gerald Kallas - mailbox.org
Thanks Mantas.

I tried it out, my route is ..

<!-- define Jackson data format -->
<dataFormats>
<json id="jackson" library="Jackson" />
</dataFormats>
<route id="isp.routes.system.deployment">
..
<setBody><constant>{"lastName": "Doo"}</constant></setBody>
<log message="json: ${in.body}" />
<!-- unmarshal JSON to Java Map -->
<unmarshal><custom ref="jackson"/></unmarshal>
<to uri="activemq:queue:IN" />
<log message="map: ${in.body}" />
<!-- process the velocity template -->
<to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=false" />

My Velocity template is ..

name=${lastName}

But I'm still missing the glue between the Java Map and the reference within the Velocity template. Tried something but nothing was successful yet.

Any hints are appreciated.

Best
- Gerald

>     Mantas Gridinas < [hidden email] mailto:[hidden email] > hat am 7. Januar 2020 um 14:14 geschrieben:
>
>
>     Not necessarily. Unmarshal EIP can be configured to unmarshal into a map.
>     Check out https://camel.apache.org/manual/latest/json.html as well as the
>     signature of DataFormatClause#json
>
>     On Tue, Jan 7, 2020, 15:09 Gerald Kallas < [hidden email] mailto:[hidden email] > wrote:
>
>
>         > >         Tx, Mantas.
> >
> >     >
>         > >         Neverthless that still means to transfer the JSON into a (pre-defined)
> >         POJO in front of Velocity processing. I wonder if there is any other way to
> >         access a JSON object directly from the Velocity engine.
> >
> >     >
>         > >         Best
> >         - Gerald
> >
> >     >
>         > >
> >             > > >             Mantas Gridinas < [hidden email] mailto:[hidden email] > hat am 7. Januar 2020 um 12:51
> > >
> > >         > >         geschrieben:
> >         >
> >         >
> >
> >             > > >             Might want to read up on Velocity user guide, then
> > >
> > >         > >         https://velocity.apache.org/engine/2.1/user-guide.html#property-lookup-rules
> >         >
> >
> >             > > >             On Tue, Jan 7, 2020 at 1:48 PM Gerald Kallas - mailbox.org
> > >             < [hidden email] mailto:[hidden email] > wrote:
> > >             >
> > >
> > >                 > > > >                 Tx for the reply. I tried this already, but the question still remains
> > > >
> > > >             > > >
> > >         > >         how to access the single attributes of the JSON tree inside Velocity
> >         component.
> >
> >             > > >
> > >                 > > > >
> > > >             > > >
> > >                 > > > >                 Best
> > > >                 - Gerald
> > > >
> > > >             > > >
> > >                 > > > >                 Am 07.01.2020 um 12:45 schrieb Mantas Gridinas < [hidden email] mailto:[hidden email] >:
> > > >                 >
> > > >
> > > >                     > > > > >                     Why not use unmarshall EIP before passing the body to velocity
> > > > >                     template? Then, as per the velocity component, you would access your
> > > > >                     body via $body variable.
> > > > >
> > > > >                 > > > >                 >> On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <
> > > >
> > > >             > > >
> > >         > >         [hidden email] mailto:[hidden email] > wrote:
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >> Hi Gerald,
> > > >                 >>
> > > >                 >> The example below shows how to use a pojo from a velocity context:
> > > >                 >>
> > > >                 >>
> > > >
> > > >             > > >
> > >         > >         https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >> So, chances are that you just need to set the body to a pojo
> > > >
> > > >             > > >
> > >         > >         offering a
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >                         getName() method and then use it from the velocity context with $
> > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >
> > > >             > > >
> > >         > >         body.name.
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >                         This is not something I've tested, but looks worth a try.
> > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >> Alex
> > > >                 >>
> > > >                 >>> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <
> > > >
> > > >             > > >
> > >         > >         [hidden email] mailto:[hidden email] > wrote:
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >
> > > > > >                             > > > > > > >
> > > > > > >                         > > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >>> Dear community,
> > > >                 >>>
> > > >                 >>> I've following snippet ..
> > > >                 >>>
> > > >                 >>>
> > > >                 >>>
> > > >
> > > >             > > >
> > >         > >         <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >
> > > > > >                             > > > > > > >                             <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
> > > > > > >
> > > > > > >                         > > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >>> The body comes from a jsonpath expression earlier. I've just
> > > >
> > > >             > > >
> > >         > >         stripped it
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >
> > > > > >                             > > > > > > >                             to the essentials.
> > > > > > >
> > > > > > >                         > > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >>> Is it possible to access inside a Camel Velocity component
> > > >
> > > >             > > >
> > >         > >         template to the
> >
> >             > > >
> > >                 > > > >
> > > >                     > > > > >
> > > > >                         > > > > > >
> > > > > >                             > > > > > > >                             attribute values for name and surname?
> > > > > > >
> > > > > > >                         > > > > > >
> > > > > >                     > > > > >
> > > > >                 > > > >                 >>> Many thanks for any response in advance.
> > > >                 >>>
> > > >                 >>> Best
> > > >                 >>> - Gerald
> > > >
> > > >             > > >
> > >         > >
> >     >
Reply | Threaded
Open this post in threaded view
|

Re: Parsing JSON within the Camel Velocity component template?

Gerald Kallas - mailbox.org
Gotcha.

The Velocity template like ..

name=${body.lastName}

did the trick.

When the JSON changes like

<setBody><constant>[{"lastName": "Doo"}]</constant></setBody>

(normally jsonpath wraps the output into an array)

then the Velocity template needs to look like ..

name=${body[0].lastName}

Thanks for any help.

Best
- Gerald

>     Gerald Kallas < [hidden email] mailto:[hidden email] > hat am 7. Januar 2020 um 19:56 geschrieben:
>
>
>     Thanks Mantas.
>
>     I tried it out, my route is ..
>
>     <!-- define Jackson data format -->
>     <dataFormats>
>     <json id="jackson" library="Jackson" />
>     </dataFormats>
>     <route id="isp.routes.system.deployment">
>     ..
>     <setBody><constant>{"lastName": "Doo"}</constant></setBody>
>     <log message="json: ${in.body}" />
>     <!-- unmarshal JSON to Java Map -->
>     <unmarshal><custom ref="jackson"/></unmarshal>
>     <to uri="activemq:queue:IN" />
>     <log message="map: ${in.body}" />
>     <!-- process the velocity template -->
>     <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=false" />
>
>     My Velocity template is ..
>
>     name=${lastName}
>
>     But I'm still missing the glue between the Java Map and the reference within the Velocity template. Tried something but nothing was successful yet.
>
>     Any hints are appreciated.
>
>     Best
>     - Gerald
>
>
>         > >         Mantas Gridinas < [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] > hat am 7. Januar 2020 um 14:14 geschrieben:
> >
> >
> >         Not necessarily. Unmarshal EIP can be configured to unmarshal into a map.
> >         Check out https://camel.apache.org/manual/latest/json.html as well as the
> >         signature of DataFormatClause#json
> >
> >         On Tue, Jan 7, 2020, 15:09 Gerald Kallas < [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] > wrote:
> >
> >
> >         > > Tx, Mantas.
> >
> >             > > >             >
> > >
> > >         > >         > > Neverthless that still means to transfer the JSON into a (pre-defined)
> >
> >             > > >             POJO in front of Velocity processing. I wonder if there is any other way to
> > >             access a JSON object directly from the Velocity engine.
> > >
> > >             >
> > >
> > >         > >         > > Best
> >
> >             > > >             - Gerald
> > >
> > >             >
> > >
> > >         > >         > >
> >
> >             > > >             > > > Mantas Gridinas < [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] > hat am 7. Januar 2020 um 12:51
> > >
> > >                 > > > >                 > > geschrieben:
> > > >
> > > >             > > >             >
> > >             >
> > >
> > >             > > > Might want to read up on Velocity user guide, then
> > >
> > >                 > > > >                 > > https://velocity.apache.org/engine/2.1/user-guide.html#property-lookup-rules
> > > >
> > > >             > > >             >
> > >
> > >             > > > On Tue, Jan 7, 2020 at 1:48 PM Gerald Kallas - mailbox.org
> > >
> > >                 > > > >                 < [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] > wrote:
> > > >                 >
> > > >
> > > >                 > > > > Tx for the reply. I tried this already, but the question still remains
> > > >
> > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > how to access the single attributes of the JSON tree inside Velocity
> > > >
> > > >             > > >             component.
> > >
> > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > > > Best
> > > >
> > > >                     > > > > >                     - Gerald
> > > > >
> > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > > > Am 07.01.2020 um 12:45 schrieb Mantas Gridinas < [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] >:
> > > >
> > > >                     > > > > >                     >
> > > > >
> > > > >                     > > > > > Why not use unmarshall EIP before passing the body to velocity
> > > > >
> > > > >                         > > > > > >                         template? Then, as per the velocity component, you would access your
> > > > > >                         body via $body variable.
> > > > > >
> > > > > >                         > > > > >> On Mon, Jan 6, 2020 at 3:19 PM Alex Dettinger <
> > > > > >
> > > > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] > wrote:
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > >
> > > > > >
> > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >> Hi Gerald,
> > > > > >
> > > > > >                     > > > > >                     >>
> > > > >                     >> The example below shows how to use a pojo from a velocity context:
> > > > >                     >>
> > > > >                     >>
> > > > >
> > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > https://github.com/apache/camel/blob/master/components/camel-velocity/src/test/java/org/apache/camel/component/velocity/VelocityBodyAsDomainObjectTest.java
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > >
> > > > > >
> > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >> So, chances are that you just need to set the body to a pojo
> > > > > >
> > > > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > offering a
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > > getName() method and then use it from the velocity context with $
> > > > > >
> > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > >
> > > > > >
> > > > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > body.name.
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > > This is not something I've tested, but looks worth a try.
> > > > > >
> > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >> Alex
> > > > > >
> > > > > >                     > > > > >                     >>
> > > > >                     >>> On Mon, Jan 6, 2020 at 12:54 PM Gerald Kallas <
> > > > >
> > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > [hidden email] mailto:[hidden email] mailto: [hidden email] mailto:[hidden email] > wrote:
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > >
> > > > > >
> > > > > >                             > > > > > > >                             > > > > > > >
> > > > > > >
> > > > > > >                                 > > > > > > > >                                 > > > > > >
> > > > > > > >
> > > > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >>> Dear community,
> > > > > >
> > > > > >                     > > > > >                     >>>
> > > > >                     >>> I've following snippet ..
> > > > >                     >>>
> > > > >                     >>>
> > > > >                     >>>
> > > > >
> > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > <setBody><constant>[{"name":"Wonderland","surname":"Alice"}]</constant></setBody>
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > >
> > > > > >
> > > > > >                             > > > > > > >                             > > > > > > > <to uri="velocity:file:{{karaf.etc}}/file.vm?contentCache=true" />
> > > > > > >
> > > > > > >                                 > > > > > > > >                                 > > > > > >
> > > > > > > >
> > > > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >>> The body comes from a jsonpath expression earlier. I've just
> > > > > >
> > > > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > stripped it
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > >
> > > > > >
> > > > > >                             > > > > > > >                             > > > > > > > to the essentials.
> > > > > > >
> > > > > > >                                 > > > > > > > >                                 > > > > > >
> > > > > > > >
> > > > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >>> Is it possible to access inside a Camel Velocity component
> > > > > >
> > > > > >                     > > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > > template to the
> > > >
> > > >             > > >             > > >
> > >
> > >                 > > > >                 > > > >
> > > >
> > > >                     > > > > >                     > > > > >
> > > > >
> > > > >                         > > > > > >                         > > > > > >
> > > > > >
> > > > > >                             > > > > > > >                             > > > > > > > attribute values for name and surname?
> > > > > > >
> > > > > > >                                 > > > > > > > >                                 > > > > > >
> > > > > > > >
> > > > > > > >                             > > > > > > >                             > > > > >
> > > > > > >
> > > > > > >                         > > > > > >                         > > > > >>> Many thanks for any response in advance.
> > > > > >
> > > > > >                     > > > > >                     >>>
> > > > >                     >>> Best
> > > > >                     >>> - Gerald
> > > > >
> > > > >                     > > >
> > > > >
> > > > >                 > > > >                 > >
> > > >
> > > >             > > >             >
> > >
> > >         > >
> >     >