Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

convert url parameters into json - Apache Nifi

avatar
Explorer

Hello Everyone,

 

Sorry if this question seems dumb, but I have query parameter (that I received via ListenHttp) in format a=value_a&b=value_b and so on, I want to convert this to json as the form given below -

 

{

"a" : "value_a",

"b" : "value_b"

.

.

}

 

I am not quite sure, but I think I should be using ReplaceText, but I am unable to understand how to write the regex. If using ReplaceText is the one I should not use on Nifi, then please do let me know how to approach the same?

 

Thanks!

Ashwin

1 ACCEPTED SOLUTION

avatar
Explorer

I was able to convert the same using replace text 

 

Search Value: (.*)=(.*)&(.*)=(.*)&(.*)=(.*)&(.*)=(.*)

Replace Value: {'$1':'$2','$3':'$4','$5':'$6','$7':'$8'}

 

Since the number of parameters for me was fixed to 4, this was enough to suffice me! If somebody has got an Idea how to do this dynamically, I am ears!

View solution in original post

1 REPLY 1

avatar
Explorer

I was able to convert the same using replace text 

 

Search Value: (.*)=(.*)&(.*)=(.*)&(.*)=(.*)&(.*)=(.*)

Replace Value: {'$1':'$2','$3':'$4','$5':'$6','$7':'$8'}

 

Since the number of parameters for me was fixed to 4, this was enough to suffice me! If somebody has got an Idea how to do this dynamically, I am ears!