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 <catsh...@mailbox.org> 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 <mgridi...@gmail.com> 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
> > <catsh...@mailbox.org> 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 <mgridi...@gmail.com>:
> > > >
> > > > 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 <
> aldettin...@gmail.com> 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 <
> catsh...@mailbox.org> 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 via email to