You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Rajith Muditha Attapattu <ra...@gmail.com> on 2019/03/25 20:29:12 UTC

using jsonpath for choice

Is there a better way to do the following ?
.when(PredicateBuilder.isEqualTo(ExpressionBuilder.languageExpression("jsonpath","$.approved"),ExpressionBuilder.constantExpression(true)))


as in
.when().jsonpath(...)

Already tried .when().jsonpath("$.approved[?(@ == true)]") and it doesn't
work.

-- 
Regards,

Rajith Muditha Attapattu <http://rajith.2rlabs.com/>

Re: using jsonpath for choice

Posted by Larry Shields <la...@gmail.com>.
Rajith,

I created an example using Alex's suggestion and it appears to be working
as expected.

Here's the sample on Github:
https://github.com/runstache/java-camel-jsonpath

hth,

Larry

On Wed, Mar 27, 2019 at 2:33 PM Alex Dettinger <al...@gmail.com>
wrote:

> Hi Rajith,
>
>   Not sure we are in the same context but I think it's worth trying this
> expression: $[?(@.approved == true)].
>
> hth,
> Alex
>
> On Tue, Mar 26, 2019 at 9:41 PM Rajith Muditha Attapattu <
> rajith77@gmail.com>
> wrote:
>
> > Thanks for the response Larry.
> > The camel version is 2.20.1
> > And I do have the camel-jsonpath dependency....
> >
> > The when clause expects a predicate, and I think it's bcos that
> expression
> > doesn't evaluate to a boolean (I stand to be correct though).
> >
> > On Mon, Mar 25, 2019 at 4:45 PM Larry Shields <la...@gmail.com>
> > wrote:
> >
> > > I'm using the Jsonpath functionality in a split() with the syntax you
> > have
> > > without any issue.  What version of camel and do you have the
> > > camel-jsonpath dependency?
> > >
> > > On Mon, Mar 25, 2019 at 4:29 PM Rajith Muditha Attapattu <
> > > rajith77@gmail.com>
> > > wrote:
> > >
> > > > Is there a better way to do the following ?
> > > >
> > > >
> > >
> >
> .when(PredicateBuilder.isEqualTo(ExpressionBuilder.languageExpression("jsonpath","$.approved"),ExpressionBuilder.constantExpression(true)))
> > > >
> > > >
> > > > as in
> > > > .when().jsonpath(...)
> > > >
> > > > Already tried .when().jsonpath("$.approved[?(@ == true)]") and it
> > doesn't
> > > > work.
> > > >
> > > > --
> > > > Regards,
> > > >
> > > > Rajith Muditha Attapattu <http://rajith.2rlabs.com/>
> > > >
> > >
> >
> >
> > --
> > Regards,
> >
> > Rajith Muditha Attapattu <http://rajith.2rlabs.com/>
> >
>

Re: using jsonpath for choice

Posted by Alex Dettinger <al...@gmail.com>.
Hi Rajith,

  Not sure we are in the same context but I think it's worth trying this
expression: $[?(@.approved == true)].

hth,
Alex

On Tue, Mar 26, 2019 at 9:41 PM Rajith Muditha Attapattu <ra...@gmail.com>
wrote:

> Thanks for the response Larry.
> The camel version is 2.20.1
> And I do have the camel-jsonpath dependency....
>
> The when clause expects a predicate, and I think it's bcos that expression
> doesn't evaluate to a boolean (I stand to be correct though).
>
> On Mon, Mar 25, 2019 at 4:45 PM Larry Shields <la...@gmail.com>
> wrote:
>
> > I'm using the Jsonpath functionality in a split() with the syntax you
> have
> > without any issue.  What version of camel and do you have the
> > camel-jsonpath dependency?
> >
> > On Mon, Mar 25, 2019 at 4:29 PM Rajith Muditha Attapattu <
> > rajith77@gmail.com>
> > wrote:
> >
> > > Is there a better way to do the following ?
> > >
> > >
> >
> .when(PredicateBuilder.isEqualTo(ExpressionBuilder.languageExpression("jsonpath","$.approved"),ExpressionBuilder.constantExpression(true)))
> > >
> > >
> > > as in
> > > .when().jsonpath(...)
> > >
> > > Already tried .when().jsonpath("$.approved[?(@ == true)]") and it
> doesn't
> > > work.
> > >
> > > --
> > > Regards,
> > >
> > > Rajith Muditha Attapattu <http://rajith.2rlabs.com/>
> > >
> >
>
>
> --
> Regards,
>
> Rajith Muditha Attapattu <http://rajith.2rlabs.com/>
>

Re: using jsonpath for choice

Posted by Rajith Muditha Attapattu <ra...@gmail.com>.
Thanks for the response Larry.
The camel version is 2.20.1
And I do have the camel-jsonpath dependency....

The when clause expects a predicate, and I think it's bcos that expression
doesn't evaluate to a boolean (I stand to be correct though).

On Mon, Mar 25, 2019 at 4:45 PM Larry Shields <la...@gmail.com>
wrote:

> I'm using the Jsonpath functionality in a split() with the syntax you have
> without any issue.  What version of camel and do you have the
> camel-jsonpath dependency?
>
> On Mon, Mar 25, 2019 at 4:29 PM Rajith Muditha Attapattu <
> rajith77@gmail.com>
> wrote:
>
> > Is there a better way to do the following ?
> >
> >
> .when(PredicateBuilder.isEqualTo(ExpressionBuilder.languageExpression("jsonpath","$.approved"),ExpressionBuilder.constantExpression(true)))
> >
> >
> > as in
> > .when().jsonpath(...)
> >
> > Already tried .when().jsonpath("$.approved[?(@ == true)]") and it doesn't
> > work.
> >
> > --
> > Regards,
> >
> > Rajith Muditha Attapattu <http://rajith.2rlabs.com/>
> >
>


-- 
Regards,

Rajith Muditha Attapattu <http://rajith.2rlabs.com/>

Re: using jsonpath for choice

Posted by Larry Shields <la...@gmail.com>.
I'm using the Jsonpath functionality in a split() with the syntax you have
without any issue.  What version of camel and do you have the
camel-jsonpath dependency?

On Mon, Mar 25, 2019 at 4:29 PM Rajith Muditha Attapattu <ra...@gmail.com>
wrote:

> Is there a better way to do the following ?
>
> .when(PredicateBuilder.isEqualTo(ExpressionBuilder.languageExpression("jsonpath","$.approved"),ExpressionBuilder.constantExpression(true)))
>
>
> as in
> .when().jsonpath(...)
>
> Already tried .when().jsonpath("$.approved[?(@ == true)]") and it doesn't
> work.
>
> --
> Regards,
>
> Rajith Muditha Attapattu <http://rajith.2rlabs.com/>
>