Testing data returned from a getJSON call

Testing data returned from a getJSON call

Happy Halloween to all
I'm using a getJSON in a javascript file I have.  I have a co-worker who on testing a change for me tells me he's getting a js error on my page, when I and others do not.  I make a getJSON call using data in my callback.  I test for data using data.length.  The error is on the 'length'.

Code:
  1. $.getJSON("get-sub-object-codes.html",{object_code:$('#tmp_object_code1').val(), type:code_type}, function(data){
  2.      $("#sub_object_code1").html('');
  3.       if( data.length > 0 ){  <-- line 2156 (below)
  4.         ...
  5.      }
  6. ...

Error:
Message: 'length' is null or not an object
Line: 2156  (see <--- in code above)

Question, is there a better way to test for data having  values?  The web-page seems to work dispite this one error, but I'd like to clean it up if I can to prevent anyone from getting the error.

Thanks for any tips.
--YankeeFan