title: Javascript: How to catch an empty Facebook Graph json object? --> { "data" : [ ] }
body: <p>I am working with Facebook Graph Api. I am getting new pages of data under the json format and when there is no more data I run into the following:</p>
  
  <p>json object:</p>
  
  <pre><code>{
    "data": [
    ]
  }
  </code></pre>
  
  <p>How can I catch this empty json in javascript? I have tried each of the following individually with no success:</p>
  
  <pre><code>if(json.data[0].length == 0){
      alert('empty');
  }
  
  if(json.data[0] == ''){
      alert('empty');
  }
  
  if (json.data.length == 0) {
      alert('empty');
  }
  
  if (json["data"].length == 0) {
      alert('empty');
  }
  </code></pre>
  
  <p>Additional details:</p>
  
  <p>This is the code where I want to check the empty data array. Everything else works fine when I receive non-empty json from Facebook.</p>
  
  <pre><code>$.get(url, function(json){
      pages[pagenumber+1]=json.paging.next;
  
      //Where I want to check for empty json
  
      $.each(json.data,function(i, data){
          $("#thumbnail"+i).attr("src", data.picture);
  });
  },'jsonp');
  </code></pre>
  
  <p>Updated....!The solution for me was to use:</p>
  
  <p>if (json.data[0])</p>