Failed to notice the JSON is “minified” (compressed so it has no spaces) in the 
flow…


From: Bob Kuhfahl <rkuhf...@mitre.org>
Reply-To: "users@nifi.apache.org" <users@nifi.apache.org>
Date: Thursday, August 16, 2018 at 9:44 AM
To: "users@nifi.apache.org" <users@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…

Reply via email to