title: JSON.Parse,'Uncaught SyntaxError: Unexpected token o
body: <p>I am having trouble with JSON returned from a web service. It looks like the JSON lacks quotes, but when I add quotes to the JSON, I get an error. Here is the error message: 'Uncaught SyntaxError: Unexpected token o. When I log the string to console:[object Object],[object Object] </p>
  
  <p>Here is some example code that simulates the error:</p>
  
  <pre><code>//Error I am trying to solve
  var jsonString = '[{"Id":"10","Name":"Matt"},{"Id":"1","Name":"Rock"}]';
  var myData = JSON.parse(jsonString);
  
  $(document).ready(function() {
      var $grouplist = $('#groups');
      $.each(myData, function() {
          $('&lt;li&gt;' + this.Name + '&lt;/li&gt;').appendTo($grouplist);
      });
  });
  </code></pre>
  
  <p>Here is the same code with the single quotes around the string. It works</p>
  
  <pre><code>//Successful Javascript
  var jsonString = '[{"Id":"10","Name":"Matt"},{"Id":"1","Name":"Rock"}]';
  var myData = JSON.parse(jsonString);
  
  $(document).ready(function() {
      var $grouplist = $('#groups');
      $.each(myData, function() {
          $('&lt;li&gt;' + this.Name + '&lt;/li&gt;').appendTo($grouplist);
      });
  });
  
  //Successful HTML
  &lt;ul id="groups"&gt;&lt;/ul&gt;
  </code></pre>
  
  <p>But when I try to add quotes to the string, like I seem to need to in my real code, it fails:</p>
  
  <pre><code>//Does not work when I need to append quotes to the string:
  var jsonStringNoQuotes = [{"Id":"10","Name":"Matt"},{"Id":"1","Name":"Rock"}];
  jsonStringQuotes = "'" + jsonStringNoQuotes + "'";
  var myData = JSON.parse(jsonStringQuotes);
  
  $(document).ready(function() {
      var $grouplist = $('#groups');
      $.each(myData, function() {
          $('&lt;li&gt;' + this.Name + ',' +  this.Id + '&lt;/li&gt;').appendTo($grouplist);
      });
  });
  </code></pre>
  
  <p>Here is the error:
  log string to console:[object Object],[object Object] 
  data.js:809 Uncaught SyntaxError: Unexpected token '</p>
  
  <p>I'm stumped. Any help appreciated! Thank you!</p>