title: Modifying a JSON object returned with PDO
body: <p>I'm trying to return use a JSON object with handlebars. Making a small todo list to learn how to use it.</p>
  
  <p>My PHP API is as follows : </p>
  
  <pre><code>$query = "SELECT *
            FROM table";
  try
  {
      $db = getConnection();
      $response = $db-&gt;query($query);
      $todo = $response-&gt;fetchAll(PDO::FETCH_OBJ);
      $bdd = null;
      echo json_encode($todo);
  }
  </code></pre>
  
  <p>It then returns something like :</p>
  
  <pre><code>[{"id":"1","todo":"Do something","who":"Me","is_done":"0"},{"id":"2","todo":"Learn JSON","who":"Me","is_done":"0"}]
  </code></pre>
  
  <p>But I'd actually need it to be like this :</p>
  
  <pre><code>{todos: [{"id":"1","todo":"Do something","who":"Me","is_done":"0"},{"id":"2","todo":"Learn JSON","who":"Me","is_done":"0"}]}
  </code></pre>
  
  <p>I tried in my PHP API to add instead of <code>echo json_encode($todo)</code></p>
  
  <pre><code>echo '{todos: ' . json_encode($todo) . '}';
  </code></pre>
  
  <p>But it doesn't work. Any ideas ?</p>