Adding on, 'RouteOnAttribute' takes ExpressionLanguage. "*$.result.status*"
is not an ExpressionLanguage (EL) but a JSON Path expression. So what you
can do is, use EvaluateJsonPath processor to read the value of status using
"$.result.status" and assign it to an attribute, say "statusField" (this
gets added as a FlowFile attribute). Connect EvaluateJsonPath with
RouteOnAttribute and reference the attribute you have added in
EvaluateJsonPath using EL. Ex: ${statusField:equals("OK")}

On Mon, Oct 15, 2018 at 6:31 PM Sivaprasanna <sivaprasanna...@gmail.com>
wrote:

> Vyshali,
>
> UpdateAttribute adds an attribute to the FlowFile i.e. just like filename,
> filesize, etc., when you set "status" : "OK" using UpdateAttribute, the
> field doesn't actually get added to the JSON content. I would rather
> suggest you to use 'UpdateRecord' processor and configure it with JSON
> Reader and JSON Writer (providing them with a schema for your JSON content)
> and set the new field "status": "OK". For more details on UpdateRecord,
> check this tutorial.
> https://community.hortonworks.com/articles/189642/update-the-contents-of-flowfile-by-using-updaterec.html
>
> -
> Sivaprasanna
>
> On Mon, Oct 15, 2018 at 6:09 PM N, Vyshali <vyshal...@honeywell.com>
> wrote:
>
>> Hi,
>>
>>
>>
>> I’m consuming the message published through “PutJMS” processor using
>> “ConsumeJMS” processor. The message is in JSON format. I added the value of
>> “*status*” as “*OK*” using “UpdateAttribute” processor. I wanted to
>> route it to “AttributesToJSON” processor if the value of *$.result.status
>> is “OK”* for which I’m using the “RouteOnAttribute” processor .The
>> regular expression which I used for routing is
>> *${status:contains(${result.status})}*. But the routing doesn’t happen
>> correctly.
>>
>>
>>
>> Sample input json :
>>
>> {
>>
>> "revision": "1.0.0",
>>
>> "acceptor": "100",
>>
>> "result": {
>>
>>                                 "status": "OK"
>>
>>                 }
>>
>> }
>>
>>
>>
>> Please let me know where I’m missing.
>>
>> Thanks in advance
>>
>>
>>
>> Regards
>>
>> Vyshali
>>
>

Reply via email to