Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Convert Attributes to JSON

Highlighted

Convert Attributes to JSON

New Contributor

I wish to convert three variables to a specific json. I am unsure of best method.

The Attributes

fromDate, toDate, id

to JSON

{

"start":"fromDate.value",

"end":"endDate.value"

"where":{ "myid": "id.value" }

}

1 REPLY 1

Re: Convert Attributes to JSON

Super Guru

@lee Arnould

As you are having attributes to the flowfile so

Use ReplaceText processor

91654-screen-shot-2018-10-08-at-82552-pm.png

Search Value

(?s)(^.*$)

Replacement Value

{ 
"start":"${fromDate}",
"end":"${endDate}",
"where":{"myid":"${id}"}
}

Character Set

UTF-8

Maximum Buffer Size

1 MB

Replacement Strategy

Always Replace

Evaluation Mode

Entire text

Output flowfile from ReplaceText will be replaced all the attributes and sends the desired format.

Don't have an account?
Coming from Hortonworks? Activate your account here