title: Converting string to a valid JSON object
body: <p>hey there i saw many questions about this topic but none of them fit my question.
  i'm trying to use localStorage to store a user custom preferences, i try put an json object into a localStorage key and use it later on.
  the object at the beginning looks like that:</p>
  
  <pre><code> Object {test: "{a:"b",c:"d"}"}
  </code></pre>
  
  <p>the <code>JSON.parse</code> method returns an error, what i done is that:</p>
  
  <pre><code>var local_storage = getAll();
  $.parseJSON(JSON.stringify(local_storage.test.substring(0,0).substring(0,local_storage.length,-1)));
  </code></pre>
  
  <p>the output is :</p>
  
  <pre><code>{a:"b",c:"d"}
  </code></pre>
  
  <p>but i can't use it as local_storage.test.a why is that and what is the solution for that?</p>
  
  <p>thx for the help :)</p>
  
  <p><strong>Edit!</strong>  </p>
  
  <p>Thanks to @Oli Soproni B, the solution is:</p>
  
  <pre><code>var key = {a:"b",c:"d"};
  var l = JSON.stringify(key);
  localStorage.setItem('test',l);
  var local_storage = $.parseJSON(localStorage.getItem('test'));
  console.log(local_storage);
  console.log(local_storage.a);
  </code></pre>