title: Mongodb take keys array listi
body: <p>I use mongoDB and I have this collection:</p>
  
  <pre><code>{
  "_id" : ObjectId("5810020c63b46a3071029031"),
  "where" : "shool",
  "referenceWork" : [ 
      {
          "role" : "teacher",
          "people" : [ 
              {
                  "name" : "lello",
                  "num" : "01"
              }, 
              {   "name" : "gigi",
                  "num" : "02"
              }, 
              {
                  "name" : "mario",
                  "num" : "03"
              }
          ]
      }, 
      {
          "role" : "janitor"
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>I need know how to get the keys of the array, like : teacher and janitor.</p>
  
  <p>My php commands:</p>
  
  <pre><code>$query = "db.people.findOne({'_id' : ObjectId('".$id."')})"; 
  $response = $db-&gt;execute($query);
  $responseJson = $response['retval']['referenceWork'] ;
  echo json_encode($responseJson);
  </code></pre>
  
  <p>Also, I don't know how to get the referenceWork length.</p>