You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Sumanth Chinthagunta <xm...@gmail.com> on 2015/11/16 21:20:59 UTC

EvaluateJsonPath error: Unable to return a scalar value for the expression

I am trying to extract data into   attribute using EvaluateJsonPath. when what JsonPath return complex type, I am getting error: Unable to return a scalar value for the expression $['data'] for FlowFile 152. Evaluated value was {id=1…..}. Transferring to failure

data  -   $.data  <—  Error 
id  -  $.data.id   <— works 
{
    "database": "test”,
    "table": "guests”,
    "type": "insert”,
    "ts": 1446422524,
    "xid": 1800,
    "commit": true,
    "data": {
        "reg_date": "2015-11-02 00:02:04",
        "firstname": "sumo",
        "id": 1,
        "lastname": "demo"
    }
}

if it possible to extract JSON object from FlowFile using EvaluateJsonPath? 
if not please advice what options I have.

Thanks
Sumo








Re: EvaluateJsonPath error: Unable to return a scalar value for the expression

Posted by Aldrin Piri <al...@gmail.com>.
The documentation is a little unclear and light.  Made a ticket [1] to
clarify how these properties are interpreted.

Thanks!

[1] https://issues.apache.org/jira/browse/NIFI-1177

On Mon, Nov 16, 2015 at 3:52 PM, Sumanth Chinthagunta <xm...@gmail.com>
wrote:

> Thanks Aldrin.
> it works after I changed Return Type to JSON.
>
> > On Nov 16, 2015, at 12:47 PM, Aldrin Piri <al...@gmail.com> wrote:
> >
> > Sumo,
> >
> > The scalar option has the processor looking for the resultant value of
> the
> > expression to provide a non-Map/List representation of the targeted
> > expression.  In this case, if you change the property to json, it should
> > work as anticipated.  The property itself is more of a validation of the
> > data that is being extracted (in that it is an object/array or a simple
> > value).
> >
> > On Mon, Nov 16, 2015 at 3:20 PM, Sumanth Chinthagunta <xmlking@gmail.com
> >
> > wrote:
> >
> >> I am trying to extract data into   attribute using EvaluateJsonPath.
> when
> >> what JsonPath return complex type, I am getting error: Unable to return
> a
> >> scalar value for the expression $['data'] for FlowFile 152. Evaluated
> value
> >> was {id=1…..}. Transferring to failure
> >>
> >> data  -   $.data  <—  Error
> >> id  -  $.data.id   <— works
> >> {
> >>    "database": "test”,
> >>    "table": "guests”,
> >>    "type": "insert”,
> >>    "ts": 1446422524,
> >>    "xid": 1800,
> >>    "commit": true,
> >>    "data": {
> >>        "reg_date": "2015-11-02 00:02:04",
> >>        "firstname": "sumo",
> >>        "id": 1,
> >>        "lastname": "demo"
> >>    }
> >> }
> >>
> >> if it possible to extract JSON object from FlowFile using
> EvaluateJsonPath?
> >> if not please advice what options I have.
> >>
> >> Thanks
> >> Sumo
> >>
> >>
> >>
> >>
> >>
> >>
> >>
> >>
>
>

Re: EvaluateJsonPath error: Unable to return a scalar value for the expression

Posted by Sumanth Chinthagunta <xm...@gmail.com>.
Thanks Aldrin. 
it works after I changed Return Type to JSON.

> On Nov 16, 2015, at 12:47 PM, Aldrin Piri <al...@gmail.com> wrote:
> 
> Sumo,
> 
> The scalar option has the processor looking for the resultant value of the
> expression to provide a non-Map/List representation of the targeted
> expression.  In this case, if you change the property to json, it should
> work as anticipated.  The property itself is more of a validation of the
> data that is being extracted (in that it is an object/array or a simple
> value).
> 
> On Mon, Nov 16, 2015 at 3:20 PM, Sumanth Chinthagunta <xm...@gmail.com>
> wrote:
> 
>> I am trying to extract data into   attribute using EvaluateJsonPath. when
>> what JsonPath return complex type, I am getting error: Unable to return a
>> scalar value for the expression $['data'] for FlowFile 152. Evaluated value
>> was {id=1…..}. Transferring to failure
>> 
>> data  -   $.data  <—  Error
>> id  -  $.data.id   <— works
>> {
>>    "database": "test”,
>>    "table": "guests”,
>>    "type": "insert”,
>>    "ts": 1446422524,
>>    "xid": 1800,
>>    "commit": true,
>>    "data": {
>>        "reg_date": "2015-11-02 00:02:04",
>>        "firstname": "sumo",
>>        "id": 1,
>>        "lastname": "demo"
>>    }
>> }
>> 
>> if it possible to extract JSON object from FlowFile using EvaluateJsonPath?
>> if not please advice what options I have.
>> 
>> Thanks
>> Sumo
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 


Re: EvaluateJsonPath error: Unable to return a scalar value for the expression

Posted by Aldrin Piri <al...@gmail.com>.
Sumo,

The scalar option has the processor looking for the resultant value of the
expression to provide a non-Map/List representation of the targeted
expression.  In this case, if you change the property to json, it should
work as anticipated.  The property itself is more of a validation of the
data that is being extracted (in that it is an object/array or a simple
value).

On Mon, Nov 16, 2015 at 3:20 PM, Sumanth Chinthagunta <xm...@gmail.com>
wrote:

> I am trying to extract data into   attribute using EvaluateJsonPath. when
> what JsonPath return complex type, I am getting error: Unable to return a
> scalar value for the expression $['data'] for FlowFile 152. Evaluated value
> was {id=1…..}. Transferring to failure
>
> data  -   $.data  <—  Error
> id  -  $.data.id   <— works
> {
>     "database": "test”,
>     "table": "guests”,
>     "type": "insert”,
>     "ts": 1446422524,
>     "xid": 1800,
>     "commit": true,
>     "data": {
>         "reg_date": "2015-11-02 00:02:04",
>         "firstname": "sumo",
>         "id": 1,
>         "lastname": "demo"
>     }
> }
>
> if it possible to extract JSON object from FlowFile using EvaluateJsonPath?
> if not please advice what options I have.
>
> Thanks
> Sumo
>
>
>
>
>
>
>
>