If you always get the string like that, i.e. keys and values in double quotes, you can add {...}
to the string and parse it as JSON:
// remove trailing comma, it's not valid JSON
var obj = JSON.parse('{' + str.replace(/,\s*$/, '') + '}');
If not, splitting the string is easy as well, assuming that ,
and :
cannot occur in keys or values:
var obj = {},
parts = str.replace(/^\s+|,\s*$/g, '').split(',');
for(var i = 0, len = parts.length; i < len; i++) {
var match = parts[i].match(/^\s*"?([^":]*)"?\s*:\s*"?([^"]*)\s*$/);
obj[match[1]] = match[2];
}