title: Unexpected token o in JSON at position 0 at JSON.parse using angular
body: <p>I have looked at simular threads, but to no success. What I'm trying to do is update my localstorage through an update function. The functions look as follows:</p>
  
  <p>The code to make the variables to call:</p>
  
  <pre><code>var localProfile = JSON.parse(localStorage.getItem("profile"));
  
  if(localProfile != undefined &amp;&amp; localProfile.length&gt;0)
  { this.profiles = localProfile; }
  
  else {
      this.profile = [
          { id: "1526", name: "berserk",      password: "berserk",    age: "31",          gender: "male"},
          { id: "1358", name: "Johnathan",    password: "test",       age: "17",          gender: "male"},
          { id: "2539", name: "Britney",      password: "test",       age: "18",          gender: "female"},
          { id: "1486", name: "Kevin",        password: "test",       age: "7",           gender: "male"},
          { id: "7777", name: "jesus",        password: "holy",       age: "unknown",     gender: "male"},
          { id: "6666", name: "satan",        password: "hell",       age: "unknown",     gender: "unknown"}
      ];
  }
  </code></pre>
  
  <p>The code to update the variable:</p>
  
  <pre><code>this.updateProfile = function(profile) {
      profile.updating = false;
      console.log(profile);
      localStorage.setItem("profile", profile);
  }
  </code></pre>
  
  <p>As I noted in the title I am currently using Angular. I have used the <code>console.log(</code>-line and the response seems to be exactly what it's supposed to be. I have tried using <code>JSON.parse(</code> and <code>JSON.stringify</code> as well as a couple of other combinations. I seem to get either the error above or another error when trying to reload the page. Apperently I either cannot execute the statement, or I end up corrupting the data so reloading the page returns a simular error.</p>
  
  <p>In case the data in variable profile is in doubt:</p>
  
  <pre><code>Array [ Object, Object, Object, Object, Object, Object ]
  </code></pre>
  
  <p>And when taking a closer look at the data:</p>
  
  <pre><code>age:"17"
  gender:"male"
  id:"1358"
  name:"johnathan"
  password:"test"
  </code></pre>
  
  <p>The other object looks identical with no weird defaults in them. I already took care of the $$hashkey just incase that was the problem.</p>
  
  <p>Any help on how to execute the call correctly is greatly apreciated and if the information is insufficient please do tell.</p>