I am faced with a JSON object that has the following structure:
{
"version" : "22",
"who: : "234234234234"
}
My goal is to convert this into a string format that can be easily sent as a raw http body request.
Essentially, I need it to be formatted as:
version=22&who=234324324324
The challenge lies in making sure this conversion works for an infinite number of parameters. Currently, I have come up with the following method:
app.jsonToRaw = function(object) {
var str = "";
for (var index in object) str = str + index + "=" + object[index] + "&";
return str.substring(0, str.length - 1);
};
However, I believe there must be a more efficient way to achieve this using native JavaScript?
Thank you.