I have a string like this:
abc=foo&def=%5Basf%5D&xyz=5
How can I convert it into a JavaScript object like this?
{
This is the simple version, obviously you'll want to add some error checking:
var obj = {}; var pairs = queryString.split('&'); for(i in pairs){ var split = pairs[i].split('='); obj[decodeURIComponent(split[0])] = decodeURIComponent(split[1]); }