var re = /\s+/g;
var str1 = str.substring(2);
var str2 = str1.substring(0, str1.length - 2);
str2 = str2.replace(re,"");
var arr = str2.split(',');
var obj = {};
arr.forEach((v, i) => {
var item = v.split(':');
obj[JSON.parse(item[0])] = JSON.parse(item[1]);
})
console.log(obj);
大概是這樣,或者可能會有所改動。