mengubah string json to object

mengubah string json to object

function strToObj(str){
   var obj = {};
   if(str||typeof str ==='string'){
       var objStr = str.match(/\{(.)+\}/g);
       eval("obj ="+objStr);
   }
   return obj
}

_https://stackoverflow.com/questions/47403708/converting-string-to-object-with-javascript