title: Insert Array inside an object in MongoDB
body: <p>I am new at MongoDB and I want to insert to mongodb data like this but I couldn't figure out how</p>
  
  <pre><code>{
    image = "cab"
    tags = [
              [ "NNP", 0 ],
              [ "NN", 1 ]
           ]
  },
  {
    image = "castle"
    tags = [
              [ "NNP", 2 ],
              [ "NN", 1 ],
           ]
  }
  </code></pre>
  
  <p>my code is</p>
  
  <pre><code>    BasicDBObject obj = new BasicDBObject();
      obj.put("images", ....);
      for(Tag tag:tags){
      BasicDBObject tagsObj = new BasicDBObject();
      tagsObj.put("NNP",tag.getNNP());
      tagsObj.put("NN",tag.getNN());
      obj.put("tags",tagsObj);
  
      }
  </code></pre>
  
  <p>UPDATE:
  using this code</p>
  
  <pre><code>Mongo m = new Mongo();
  DB db = m.getDB("test");
  DBCollection coll = db.getCollection("tags");
  for(Tag tag:tags){
      BasicDBList dbl = new BasicDBList();
      dbl.add(new BasicDBObject("NNP",tag.getNNP()));
      dbl.add(new BasicDBObject("NN", tag.getNNP()));
      BasicDBObject outer=new BasicDBObject("images", currentImageName).append("tags", dbl);
      coll.insert(outer);
                  }
  </code></pre>
  
  <p>I store every image alone cause the tags might be like this for the same image</p>
  
  <pre><code>  {
        image = "cab",
        tags = [
                  { "NNP", 0 },
                  { "NN", 1 }
               ],
               [  {"NNP", 4 },
                  { "NN", 5 } 
               ],
               [
                  {"NNP", 0 },
                  { "NN", 4 }
               ]
  </code></pre>
  
  <p>},</p>
  
  <p>Thanks</p>