title: retrieve values from nested json array in mongodb
body: <p>My mongo collection has entries in the following format</p>
  
  <pre><code>{
      "myobj" : {
          "objList" : [
              { "location" : "Texas" },
              { "location" : "Houston"},
              { "name":"Sam" }
          ]
      }, 
      "category" : "cat1"
  }
  
  
  {
  "myobj" : 
  {
      "objList" : [
          { "location" : "Tennesy" },
          { "location" : "NY"},
          { "location" : "SF" }
      ]
  }, 
  "category" : "cat2"
  
  }
  </code></pre>
  
  <p>I want to extract the <code>"**category**"</code> where <code>location</code> is <code>"Houston"</code>. In case of simple JSON object I have to just pass it as query like: </p>
  
  <pre><code>BasicDBObject place = new BasicDBObject();
  place.put("location", "Houston");
  </code></pre>
  
  <p>But in case of nested JSON I don't know how to pass it as a query and get the appropriate <strong>category</strong>. ie If I pass my location as"Houston" then it should return it's appropriate category "cat1"...i hope my question is clear now....</p>