title: Wordpress global $wpdb; returns unwanted 'null' text
body: <p>I am using wordpress with JSON REST API plugin (<a href="http://wordpress.org/plugins/json-rest-api/" rel="nofollow noreferrer">http://wordpress.org/plugins/json-rest-api/</a>).</p>
  
  <p>I am able to create my custom endpoint. At this case I create endpoint for displaying 5 users.</p>
  
  <p>This is my code: </p>
  
  <pre><code>class JSON_API_Pmbs_Controller
  {
    public function user_search()
    {
  
      global $wpdb;
      $query = "SELECT * FROM pmbsn_users LIMIT 0,3";
      $blogusers = $wpdb-&gt;get_results($query);
      $return_array = array();
      foreach ($blogusers as $user)
      {
          $avatar_url = get_avatar_url ( get_the_author_meta($user-&gt;ID), $size = '50' ); 
  
          $current_array = array(
              'thumbnail' =&gt; $avatar_url,
              'display_name' =&gt; $user-&gt;display_name,
              'user_url' =&gt; site_url().'/members/'.$user-&gt;user_login
              );
  
          array_push($return_array, $current_array);
      }
  
      $echo_json = json_encode($return_array, JSON_PRETTY_PRINT);
      echo $echo_json;
    }
  }
  </code></pre>
  
  <p>And this is the JSON result:</p>
  
  <pre><code>[
  {
      "thumbnail": "http:\/\/0.gravatar.com\/avatar\/?d=identicon&amp;amp;s=50",
      "display_name": "PMBS Admin",
      "user_url": "http:\/\/localhost\/web_pmbsnetwork\/members\/pmbsadmin"
  },
  {
      "thumbnail": "http:\/\/0.gravatar.com\/avatar\/?d=identicon&amp;amp;s=50",
      "display_name": "Johan HS",
      "user_url": "http:\/\/localhost\/web_pmbsnetwork\/members\/johan"
  },
  {
      "thumbnail": "http:\/\/0.gravatar.com\/avatar\/?d=identicon&amp;amp;s=50",
      "display_name": "Seno Adi W",
      "user_url": "http:\/\/localhost\/web_pmbsnetwork\/members\/seno"
  }
  ]null
  </code></pre>
  
  <p>You guys may notice that there is a strange 'null' text in the end of json result.</p>
  
  <p>After debug, I found out that was from <code>global $wpdb</code>.</p>
  
  <p>I have been doing:</p>
  
  <ol>
  <li>Include wp-load.php (<a href="http://wordpress.org/support/topic/wpdb-returning-null" rel="nofollow noreferrer">http://wordpress.org/support/topic/wpdb-returning-null</a>)</li>
  <li>Include all (maybe required) files (<a href="https://stackoverflow.com/questions/5306612/using-wpdb-in-standalone-script">Using WPDB in standalone script?</a>)</li>
  <li>Set global $wpdb = "foo" (<a href="https://stackoverflow.com/questions/18469059/wpdb-is-null-even-after-global-wpdb">$wpdb is null even after &#39;global $wpdb</a>)</li>
  </ol>
  
  <p>But no success. How can I remove the null text in the end of my JSON result?</p>
  
  <p>Thanks.</p>