Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Nifi Remove double quotes in attribute value

avatar
Explorer

I have an EvaluateJsonPath processor which adds the client id as an attribute to a flow file, client id is an integer without any double quotes, but when I later retrieve this and few other attributes using a AttributeToJson processor and get the results as a JSON output I get the client ID with double quotes in the following format:

clientid : "2"

I tried with JOLTTransformJSON processor too with following configuration:

[ { "operation": "default", "spec": { "clientid":"${clientid}" } } ]

and also with the replace function in an updateAttribute processor to replace double quotes but still I get it with double quotes, how can I get rid of the double quotes in resultant JSON.

1 REPLY 1

avatar
Master Guru

@Ranith Ranawaka

After Attributes to Json processor use Replace Text processor with

Search Value

"clientid"\s+:\s+"(.*)"

Replacement Value

"clientid" : $1

Replacement Strategy

Regex Replace

Evaluation Mode

Entire text

Configs:-

44405-replace.png

Input:-

{
"clientid" : "2",
"id":"1",
"name":"HCC"
}
Output:-
{
"clientid" : 2,
"id":"1",
"name":"HCC"
}

So we are searching for the value of client id and replacing the value without quotes by using replace text processor.