title: Checking the first element of json
body: <p>I am very new to Json and need to access elements of json:</p>
  
  <pre><code>$users=User::all()-&gt;toJson();
  </code></pre>
  
  <p><code>print_r($users[0])</code> gives only <code>[</code></p>
  
  <p>and <code>print_r($users[0]-&gt;email)</code> gives me the error trying to get property of non object.</p>
  
  <p><code>$users[0]["email"]</code> gives Illegal string offset 'email'.</p>
  
  <p><code>$users[0].email</code> Use of undefined constant name - assumed 'email'</p>
  
  <p>How do i get the name of first user?</p>