You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by James McMahon <js...@gmail.com> on 2018/08/15 18:02:07 UTC

Detect a pattern in incoming json content

Good afternoon. I have a requirement to search for and detect a pattern
"request":"false" is anywhere in the content of a flowfile. The content is
json that spans multiple lines. My reuest key and value would be on its own
line, embedded within a tag like this

"options":"{
        "abc":""12345"
        "request":"false",
         .
         .
         }"

Is there a standard processor that I could use to read my json and search
for these tokens?
Thanks veyr much.
Jim

Re: Detect a pattern in incoming json content

Posted by James McMahon <js...@gmail.com>.
EvaluateJSONPath - I'll give that a try. I can't rule out such edge cases.
Thank you very much Andy.

On Thu, Aug 16, 2018 at 12:21 PM, Andy LoPresto <al...@apache.org>
wrote:

> Jim,
>
> If the JSON can span multiple lines, you may also want to use
> EvaluateJSONPath to extract the value of the *request* key and then
> RouteOnAttribute accordingly. Might be slightly more expensive, but may
> catch edge cases that a regex would have trouble with.
>
> Andy LoPresto
> alopresto@apache.org
> *alopresto.apache@gmail.com <al...@gmail.com>*
> PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69
>
> On Aug 16, 2018, at 3:44 AM, James McMahon <js...@gmail.com> wrote:
>
> Thanks very much for your reply, Mark. Because the description for
> RouteText says that it routes each line of the content individually, that
> is not what I will use in my case. The requirement I have is to route the
> entire flowfile based on whether or not the tokens of interest match
> anywhere in the flowfile. I think RouteOnContent is just the thing for me,
> I just need to more carefully define my regex pattern. Thank you again for
> your help. -Jim
>
> On Wed, Aug 15, 2018 at 2:06 PM, Mark Payne <ma...@hotmail.com> wrote:
>
>> Jim,
>>
>> I'd recommend RouteText. ScanContent would also be an alternative.
>>
>> Thanks
>> -Mark
>>
>>
>> > On Aug 15, 2018, at 2:02 PM, James McMahon <js...@gmail.com>
>> wrote:
>> >
>> > Good afternoon. I have a requirement to search for and detect a pattern
>> "request":"false" is anywhere in the content of a flowfile. The content is
>> json that spans multiple lines. My reuest key and value would be on its own
>> line, embedded within a tag like this
>> >
>> > "options":"{
>> >         "abc":""12345"
>> >         "request":"false",
>> >          .
>> >          .
>> >          }"
>> >
>> > Is there a standard processor that I could use to read my json and
>> search for these tokens?
>> > Thanks veyr much.
>> > Jim
>>
>>
>
>

Re: Detect a pattern in incoming json content

Posted by Andy LoPresto <al...@apache.org>.
Jim,

If the JSON can span multiple lines, you may also want to use EvaluateJSONPath to extract the value of the *request* key and then RouteOnAttribute accordingly. Might be slightly more expensive, but may catch edge cases that a regex would have trouble with.

Andy LoPresto
alopresto@apache.org
alopresto.apache@gmail.com
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Aug 16, 2018, at 3:44 AM, James McMahon <js...@gmail.com> wrote:
> 
> Thanks very much for your reply, Mark. Because the description for RouteText says that it routes each line of the content individually, that is not what I will use in my case. The requirement I have is to route the entire flowfile based on whether or not the tokens of interest match anywhere in the flowfile. I think RouteOnContent is just the thing for me, I just need to more carefully define my regex pattern. Thank you again for your help. -Jim
> 
> On Wed, Aug 15, 2018 at 2:06 PM, Mark Payne <markap14@hotmail.com <ma...@hotmail.com>> wrote:
> Jim,
> 
> I'd recommend RouteText. ScanContent would also be an alternative.
> 
> Thanks
> -Mark
> 
> 
> > On Aug 15, 2018, at 2:02 PM, James McMahon <jsmcmahon3@gmail.com <ma...@gmail.com>> wrote:
> >
> > Good afternoon. I have a requirement to search for and detect a pattern "request":"false" is anywhere in the content of a flowfile. The content is json that spans multiple lines. My reuest key and value would be on its own line, embedded within a tag like this
> >
> > "options":"{
> >         "abc":""12345"
> >         "request":"false",
> >          .
> >          .
> >          }"
> >
> > Is there a standard processor that I could use to read my json and search for these tokens?
> > Thanks veyr much.
> > Jim
> 
> 


Re: Detect a pattern in incoming json content

Posted by James McMahon <js...@gmail.com>.
Thanks very much for your reply, Mark. Because the description for
RouteText says that it routes each line of the content individually, that
is not what I will use in my case. The requirement I have is to route the
entire flowfile based on whether or not the tokens of interest match
anywhere in the flowfile. I think RouteOnContent is just the thing for me,
I just need to more carefully define my regex pattern. Thank you again for
your help. -Jim

On Wed, Aug 15, 2018 at 2:06 PM, Mark Payne <ma...@hotmail.com> wrote:

> Jim,
>
> I'd recommend RouteText. ScanContent would also be an alternative.
>
> Thanks
> -Mark
>
>
> > On Aug 15, 2018, at 2:02 PM, James McMahon <js...@gmail.com> wrote:
> >
> > Good afternoon. I have a requirement to search for and detect a pattern
> "request":"false" is anywhere in the content of a flowfile. The content is
> json that spans multiple lines. My reuest key and value would be on its own
> line, embedded within a tag like this
> >
> > "options":"{
> >         "abc":""12345"
> >         "request":"false",
> >          .
> >          .
> >          }"
> >
> > Is there a standard processor that I could use to read my json and
> search for these tokens?
> > Thanks veyr much.
> > Jim
>
>

Re: Detect a pattern in incoming json content

Posted by Mark Payne <ma...@hotmail.com>.
Jim,

I'd recommend RouteText. ScanContent would also be an alternative.

Thanks
-Mark


> On Aug 15, 2018, at 2:02 PM, James McMahon <js...@gmail.com> wrote:
> 
> Good afternoon. I have a requirement to search for and detect a pattern "request":"false" is anywhere in the content of a flowfile. The content is json that spans multiple lines. My reuest key and value would be on its own line, embedded within a tag like this
> 
> "options":"{
>         "abc":""12345"
>         "request":"false",
>          .
>          .
>          }"
> 
> Is there a standard processor that I could use to read my json and search for these tokens?
> Thanks veyr much.
> Jim