I am looking to convert a json request input into a specific format required by the backend using javascript. Can anyone suggest the best way or steps to achieve this? Any assistance will be highly appreciated! Thank you.
The request input is as follows:
{
"Product": "abc"'
"Data": "{"Name":"John","Email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="22484d4a4c62475a57353484705252655304010e"><span class="__cf_email__" data-cf-email="6b08041a1d19081a0b27061507145418151d">[email protected]</span></a>"}"
}
The desired output to send to the backend should be in the following format:
{
"variables": {
"Product": {
"value": "abc",
"type": "string"
},
"Data": {
"value": "{"Name":"John","Email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97fdf8fff9d7f2eff6fae7fbf267aaaab5aaad8dcff2fcfb">[email protected]</a>"}",
"type": "string"
}
},
"Key": "123"
}
Thank you in advance!