title: Get first property key of JSON for a TreeView
body: <p>Thanks for the answers on the previous two questions. I have a new one, and this one is a collapsible panel in jQuery. The concept is, the <strong>first</strong> key of a JSON object will appear as a button, and the other keys will be treated as regular text like <code>&lt;p&gt;</code> and the like. </p>
  
  <p>I have this function which tests for the first index of an object.</p>
  
  <pre><code>function isFirstIndex(obj){
  var key;
  for(key in obj){
      if(obj[key]===0){
          return true;
      }
    }
    return false;
  }
  </code></pre>
  
  <p>I have tried this one:</p>
  
  <pre><code>function generateTree(data, selId){
  var cnt = "";
  for (var i=0; i&lt;5; i++){
          var row = data[i];
          $.each(row, function(key,value){
              if (isFirstIndex(row)){
                  cnt += "&lt;button&gt;" + value + "&lt;/button&gt;&lt;br/&gt;";
              } else{
                  cnt += "&lt;strong&gt;" + key + "&lt;/strong&gt; :" + value + "&lt;br/&gt;";
              }
  
          });
          cnt += "&lt;br/&gt;";
       }
  
       $(selId).html(cnt);
  }
  </code></pre>
  
  <p>But eventually found out in debugging that the <code>key</code> in the <code>isFirstIndex</code> function is compared with a string. 
  Suppose I have a JSON : </p>
  
  <pre><code>{"userId" : 1, "name" : "cool name"}
  </code></pre>
  
  <p>I want to show the first key of any JSON set as a button, and the following properties will be ordinary text. Please allow me to post a <code>pseudo-code</code> like process.</p>
  
  <pre><code>Loop through all elements of data response
      Loop through each key and value of each data element.
          If the key is the first occurrence within the data set
              display it as a button.
          else
              display it as ordinary text.
      End Inner Loop
  End outer loop
  </code></pre>