You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Jean-Sebastien Vachon <js...@brizodata.com> on 2021/12/21 20:18:23 UTC

Passing single and double-quotes as part of parameters

Hi all,

I'm trying to configure an ExecuteStreamCommand processor that will simply receive a JSON array such as ["1 2", "3 4"]
and merge everything into a single line.

I can do it easily with jq from the command line

echo '["1 2", "4 5"]' |jq 'join(" ")'
"1 2 4 5"

I am running into issues when specifying the parameters. Nifi is complaining about "Unix shell encoding issues"... I have tries escaping with \, doubling the quotes but nothing seems to work.

I checked the documentation and I couldn't find any reference to escaping except for variables

Any idea?

Jean-Sébastien Vachon
Co-Founder & Architect
Brizo Data, Inc.
www.brizodata.com<https://outlook.office365.com/mail/options/mail/messageContent/www.brizodata.com>

Re: Passing single and double-quotes as part of parameters

Posted by Jo...@swisscom.com.
Hi Jean-Sébastien

I’ve done a quick test for you and the following doesn’t produce an error, but it doesn’t exactly do what you want as the result for the flowfile content is the following: '[1 2, 4 5]' |jq 'join( )'

[Graphical user interface, text, application, email  Description automatically generated]

I’m not an expert but I’m guessing that piping doesn’t work in the ExecuteStreamCommand processor. So to achieve what you want you probably have to use two processors. One for the “echo” and one for the “jq” part.
I don’t know your exact use case, but I would use the “Extract Text” processor instead of the first echo and maybe there are other ways to achieve what you want with the NiFi included JSON processors (like the JoltTransformJSON).

Cheers
Josef


From: Jean-Sebastien Vachon <js...@brizodata.com>
Reply to: "users@nifi.apache.org" <us...@nifi.apache.org>
Date: Tuesday, 21 December 2021 at 21:18
To: "users@nifi.apache.org" <us...@nifi.apache.org>
Subject: Passing single and double-quotes as part of parameters

Hi all,

I'm trying to configure an ExecuteStreamCommand processor that will simply receive a JSON array such as ["1 2", "3 4"]
and merge everything into a single line.

I can do it easily with jq from the command line

echo '["1 2", "4 5"]' |jq 'join(" ")'
"1 2 4 5"

I am running into issues when specifying the parameters. Nifi is complaining about "Unix shell encoding issues"... I have tries escaping with \, doubling the quotes but nothing seems to work.

I checked the documentation and I couldn't find any reference to escaping except for variables

Any idea?

Jean-Sébastien Vachon
Co-Founder & Architect
Brizo Data, Inc.
www.brizodata.com<https://outlook.office365.com/mail/options/mail/messageContent/www.brizodata.com>