Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

problem while using RouteOnAttribute (cannot read json attribute and always sends flow to unmatch)

Ask Question

while using RouteOnAttribute nifi processor , i have input of json data

[{"dev":"xyz","detail":"abc"}] which i got from convertRecord processor

Routing Strategy :Route to Property name

ifmatch: ${dev:equals( "xyz" )}

I tried ${dev:matches( "xyz")} in both single quotes and double quotes still am not getting flowfile redirecting towards "ifmatch" . its redirecting to unmatched

is there anyway to resolve this i tried many other option

The flowfile content is different from attributes . Content is arbitrary -- could be empty, text, KB of XML, GB of video or binary. Each flowfile also has attributes which are key/value pairs of String s kept in memory.

If you want to route on this piece of data, you have multiple options:

  • Use RouteOnText or RouteOnContent to use the actual flowfile content directly.
  • Extract it to an attribute using EvaluateJsonPath and then route on that attribute.
  • The Apache NiFi User Guide and In-Depth provide more information around this distinction.

    Am using EvaluateJsonPath and below is my configuration Destination:flowfile-attribute Return Type: auto-detect Path Not Found Behavior: warn Null Value Representation :empty string Device : $.dev i am getting Device as empty string when i check in flowfile attributes is their any particular reason Manmit Aug 14, 2020 at 8:44 Your content is an array of JSON objects, not a single one, so you'll need something like $[0].dev to extract the dev key/value pair from the first (zero-indexed) element of the array. Andy Aug 18, 2020 at 23:48

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .