title: JSON.parse object returning undefined values
body: <p>I have an ajax request that returns some pretty basic data from a form submit, as shown.</p>
  
  <p>PHP:</p>
  
  <pre><code>if ( ! empty($errors)) {
  
      // if there are items in our errors array, return those errors
      $data['success'] = false;
      $data['errors']  = $errors;
  } else {
  
      $outputArray = array();
  
      $outputArray[] = array(
          'students' =&gt; base64_encode($_POST['students']),
          'sub' =&gt; $_POST['subject'],
          'topic' =&gt; $_POST['topic'],
          'class' =&gt; $_POST['class'],
          'checked' =&gt;  $_POST['checked'],
          'pronoun' =&gt; $_POST['slider']
      );
  
      // if there are no errors process our form, then show a message of success and provide a true success variable
      $data['success'] = true;
      $data['message'] = json_encode($outputArray);
  }
  
  // return all our data to an AJAX call
  echo json_encode($data);
  </code></pre>
  
  <p>Javascript:</p>
  
  <pre><code>$.ajax({
      type: 'POST',
      url: 'processBatch.php',
      data: formData,
      dataType: 'json',
      encode: true
  })
  
  .done(function(data) {
      if (!data.success) {
          // error handling goes here. Removed for clarity. 
      } else {
          // ALL GOOD!
          console.log(data.message);
  
          var obj1 = $.parseJSON(data.message);
          var obj2 = JSON.parse(data.message);
  
          console.log("Subject is: " + obj1.sub);
          console.log("Subject is: " + obj2.sub);
      }
  }
  </code></pre>
  
  <p>On the face of it, all seems good - the returned data seems to be valid JSON (JSONlint clears it as being valid), but when I use <code>JSON.parse</code> to convert it to an object, and try to reference the values in that object, the returned value is always undefined. I've also tried <code>$.parseJSON</code> and the result is the same. </p>
  
  <p>Everything <em>looks</em> okay to me, so any advice would be appreciated. </p>
  
  <p>SAMPLE RETURNED STRING</p>
  
  <pre><code>[{
      "students": "TWlrZQpCb2IK",
      "sub": "English",
      "topic": "Test topic",
      "class": "Test classname",
      "checked": "WzEsNSw5XQ==",
      "pronoun": "2"
  }]
  </code></pre>