Support Questions
Find answers, ask questions, and share your expertise

convert url parameters into json - Apache Nifi

New Contributor

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

New Contributor

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

New Contributor

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!

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.