title: get key name from json object
body: <p>This is almost exactly the same as this question <a href="https://stackoverflow.com/questions/4222596/json-get-key-names-as-text">json get key names as text?</a>, but that response isn't working for me. </p>
  
  <p>I've got a json object</p>
  
  <pre>
  {"userList":[
  {"user1":[{"username":"mike","memberSince":"01/03/2011"}]},
  {"user2":[{"username":"john","memberSince":"01/05/2011"}]},
  ]}
  </pre>
  
  <p>The only reason I have a the "user1" and "user2" labels is because I'm storing the userlist by userId in jQuery data, and then stringifying it to put it in a cookie and send it in another page. I know, sounds stupid, but I'm just building some front end stuff to prove a point before doing this properly with a db. </p>
  
  <p>So the </p>
  
  <pre>
  jQuery('div#userList').data('user1',user1JSON);
  </pre>
  
  <p>turns into </p>
  
  <pre>
  {"user1":[{"username":"mike","memberSince":"01/03/2011"}]}
  </pre>
  
  <p>when using </p>
  
  <pre>
  var userlist=JSON.stringify(jQuery('div#userList').data());
  </pre>
  
  <p>Because of this, the user info is now a child of the userId, instead of just being a child of userlist.</p>
  
  <p>In order to get the user info, I should be able to say </p>
  
  <pre>
  for(u=0;u&lt;userList.length;u++){
     var userInfo=userList[u][0];
  }
  </pre>
  
  <p>but unfortunately this is just giving me an undefined error. If I use</p>
  
  <pre>
  var userInfo = userList[u]['user1'];
  </pre>
  
  <p>I get the user info correctly. </p>
  
  <p>So, can somebody correct me as to why userList[u][0] does not work, OR</p>
  
  <p>explain to me how to use JSON.stringify without adding the userid to the beginning of the string?</p>