title: json_encode($myObject) dont want reveal my whole object
body: <p>Our PHP application makes use of json_encode($myObject) a lot, in conjunction with the mustache template library.  It's awesome.  </p>
  
  <p>Trouble is, when returning json data from an ajax request it reveals the whole stucture of our objects, even if we don't have data assigned to them.  A simple example:</p>
  
  <p>Fetch a user via ajax and let the server return the object with json_encode($user)</p>
  
  <p>The json:</p>
  
  <p><code>"_userID":"1","_password":null,"_avatar":"0000723_8949d1d7eb0214fdf6c1af3cb6b66ed3_a.jpg","_blocked":null,"_confirmed":null,"_registerDate":null,"_lastVisitDate":null,"_template":null,"_referrerUserID":null,"_referrerURL":null,"_referrerDomain":null,"_referrerSearchTerms":null,"_confirmationHash":null,"_type":"Administrator"</code> and so on...</p>
  
  <p>It reveals a lot about our objects when all I wanted to return was just a few fields.</p>
  
  <p>Obviously I could rewrite our server side code to send back an array or different objects which are more limited but really that makes life harder and sort of prevents our clean template design which handles the same objects as our server does.</p>
  
  <p>How do I clear all null properties from a json_encode.  Does anybody else have this issue and a nice and clean solution?</p>