I think this would be a fairly easy lift because Jackson's ObjectMapper in 2.X is thread safe. We'd just need to put a warning in the documentation saying "this might be a somewhat heavy method so be careful."
I can make a PR for this pretty quickly. On Fri, Oct 7, 2022 at 11:11 AM David Handermann <[email protected]> wrote: > > Hi Dan, > > It seems like this could be helpful, although accurate detection might be > difficult. It could be as simple as checking whether a string starts with a > curly bracket or square bracket character. Another option would be > attempting to parse the string using a JSON library, since that could cover > additional bases. Either way, having sufficient unit tests and > documentation would be helpful depending on the implementation approach. > > Regards, > David Handermann > > On Fri, Oct 7, 2022 at 10:06 AM Pierre Villard <[email protected]> > wrote: > > > Hi Dan, > > > > I personally think this is a fair addition to the expression language > > options we have. Feel free to file a JIRA and submit a pull request if > > you'd like to do so. > > > > Thanks, > > Pierre > > > > Le ven. 7 oct. 2022 à 08:34, Dan S <[email protected]> a écrit : > > > > > My team has flow file attributes which we do not always know whether they > > > are JSON or not. We would like to run JsonPath on them but when they are > > > not JSON we get flow files yielding as detailed in NIFI-10396 > > > <https://issues.apache.org/jira/browse/NIFI-10396>. I understand the > > > reasons given there not to support the patch but I was thinking of > > possibly > > > another solution which could short circuit the issue. I wanted to > > propose a > > > new Expression Language method isJson which would determine whether an > > > attribute is JSON or not. This would allow for determining whether an > > > attribute is JSON and pass it along to JsonPath or route accordingly when > > > it is not JSON. Does that sound reasonable? > > > > >
