Support Questions

Find answers, ask questions, and share your expertise

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!