text: Q:
  
  String to object in Javascript
  
  I have a function working fine:
  function sendLeadData(form) {
      return trk(form, {
          firstName: "pan",
      });
  }
  
  {firstName : "Pan"} = an object. If I set this to a var and pass the var in function that also works fine. But I need to use a string which I am building from some map and pass that. I am getting the string perfect .Code below not working:
  function sendLeadData(form) {
      //code to get str
      alert("str is "+str);------->prints str perfect,also giving result below
      var obj = JSON.parse(str);//If except str I put JSON.parse(JSON.stringify({firstName:"Pan"})) that work fine
      alert("obj is "+obj);
  
      return trk(form,
          obj
      );
  }
  
  str prints "{firstName:"Pan"}". Error is syntax error thrown.
  Please help.
  
  A:
  
  JSON has more strict object representation. The keys also need to be quoted:
  '{"firstName": "Pan"}'
  
  