title: How to access a subDocumet of subDocument using DBObject
body: <p>I need to get a list of all the name fields from the following json.  I'm trying to do this by mapping a DBObject.</p>
  
  <p>JSON:</p>
  
  <pre><code>{
      "firstOne": [
          {
              "file": "FileA",
              "Data": "One",
              "version": "0.4"
          }
      ],
      "secondOne": [
          {
              "elementName": "version",
              "complexElement": "true",
              "elementDataType": ""
          }
      ],
      "ThirdOne": [
          {
              "elementName": "version",
              "explicitElements": [
                  {
                      "name": "mytag",
                      "type": "String",
                      "value": "myrequest"
                  },
                  {
                      "name": "booleantest",
                      "type": "Boolean",
                      "value": "true"
                  }
              ]
          }
      ] }
  </code></pre>
  
  <p>CODE:</p>
  
  <blockquote>
    <p>DBCollection collection = mongoTemplate.getCollection("testTag");</p>
  
  <pre><code>  Map&lt;DBObject, DBObject&gt; map = new HashMap&lt;DBObject, DBObject&gt;();
    DBObject obj =null;
  
    BasicDBObject query = new BasicDBObject();
    query.put("ThirdOne.explicitElements.name", "myTag");
    BasicDBObject fields = new BasicDBObject();
    fields.put("ThirdOne.explicitElements.name", 1);
    fields.put("ThirdOne.explicitElements.value", 1);
  
    DBCursor cursor2 = collection.find(query, fields);      while
  </code></pre>
    
    <p>(cursor2.hasNext()) {             obj = cursor2.next();           map = obj.toMap();</p>
  
  <pre><code>      for (Map.Entry&lt;DBObject, DBObject&gt; entry : map.entrySet()) {
            System.out.println("Key : " + entry.getKey() + " Value : "
                    + entry.getValue());
  
  
        }
                }
  </code></pre>
  </blockquote>
  
  <p>RESULTS:</p>
  
  <blockquote>
    <p>key: _id Value: 523f910681a9535f8af5aa91</p>
    
    <p>Key: ThirdOne Value: [{ "explicitElements" : [{"name":"mytag",
    "value":"myrequest"},{"name":"booleantest", "value":"true"}]}]</p>
  </blockquote>
  
  <p>I would like to get only</p>
  
  <blockquote>
    <p>key: "name"  value: "mytag" </p>
    
    <p>key: "value"   value: "myrequest"  etc...</p>
  </blockquote>
  
  <p>Any suggestions on how to do this using DBObjects?</p>