You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by "Kuhfahl, Bob" <rk...@mitre.org> on 2018/08/16 15:40:01 UTC
OPS : ReplaceText regex question
Failed to notice the JSON is “minified” (compressed so it has no spaces) in the flow…
From: Bob Kuhfahl <rk...@mitre.org>
Reply-To: "users@nifi.apache.org" <us...@nifi.apache.org>
Date: Thursday, August 16, 2018 at 9:44 AM
To: "users@nifi.apache.org" <us...@nifi.apache.org>
Subject: ReplaceText regex question
I have to massage some JSON to pass into PutDatabaseRecord so I can insert the data into postgresql.
Postgres wants the identifers to have double quotes and it seems the values need to have single quotes (for the strings).
Sample JSON input:
"producer_userid": "fdolomite",
Search Value:
(?<=\": )\"(.+)\"
Replacement Value:
'$1'
I can get a small java program to use the above and replace the “ (double quotes) around the value to ‘ (single quotes) e.g.:
"producer_userid": ‘fdolomite’,
But… ReplaceText is not doing it. I’ve tried surrounding the search & replacement values in quotes (pretty sure that was not the problem, but heh).
All I get in the log file is it moved the flow to success.
From reading the source code for ReplaceText , it’s using the Java Pattern() and replaceAll() so I think my sample program is doing the same work, including matcher.find()
So I must be missing something…