That's a really clever solution, Ryan. Out of the box there is no assertion to just do this, and I would have probably used a split on the string then looped through it to build it up, but your regex solution is waaaay more elegant. Thanks!
------------------------------
Jay MacDonald - Adoption Architect - Broadcom API Management (Layer 7)
------------------------------
Original Message:
Sent: 12-16-2019 12:41 PM
From: Ryan Kennell
Subject: Re: How to convert an x-www-form-urlencoded string to JSON?
I am not sure if there is an out-of-the box solution, but you can use a regex to replace the url-encoded delimiter (&) with the json delimiter (","). then another regex to replace the url-encoded key/val assignment (=) with ":". your string will look like this:
ToCountry": "US","ToState": "VT","SmsMessageSid": "SM432455e26341f85176300721a9689dca","NumMedia": "0","ToCity": "NORTON
use the "set context variable" assertion to append the beginning {" and ending "}
------------------------------
Software Developer II
FedEx Services
Original Message:
Sent: 12-16-2019 12:14 PM
From: Prem Arumugam
Subject: Re: How to convert an x-www-form-urlencoded string to JSON?
Hello All,
I'm trying to convert X-www-form-urlencoded string to JSON message and pass over to backend. Please find the sample message below
ToCountry=US&ToState=VT&SmsMessageSid=SM432455e26341f85176300721a9689dca&NumMedia=0&ToCity=NORTON&FromZip=07662&SmsSid=SM432455e26341f85176300721a9689dca&FromState=NJ&SmsStatus=received&FromCity=ROCHELLE+PARK&Body=Hello&FromCountry=US&To=%2B18024350042&ToZip=05907&NumSegments=1&MessageSid=SM432455e26341f85176300721a9689dca&From=%2B12012537162&ApiVersion=2010-04-01
Could anyone please help me with that.
Regards,
Prem.