title: C cannot retrieve mongodb BSON array
body: <p>I meet a problem on C program connect to mongodb to retrieve document...I dont know how to solve it, please help...    </p>
  
  <p>The record structure : </p>
  
  <pre><code>{ "District" : "HK", 
    "Contact": [ {"name":"Person A","telephone":"1111-1111"} ,   
                 {"name":"Person B", "telephone":"2222-2222}  ] 
  }
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>while( mongo_cursor_next( cursor ) == MONGO_OK ){
      bson_iterator iterator[1];
      //print district
      if ( bson_find( iterator, mongo_cursor_bson( cursor ), "District" )) {  
          printf( "District: %s\n", bson_iterator_string( iterator ) );  
  
      //print array elements
      if ( bson_find( iterator, mongo_cursor_bson( cursor ), "Contact" )) {
          bson_iterator subit[1];
          bson_iterator_subiterator(iterator, subit);
  
          //get array list element one by one
          while(bson_iterator_more(subit)){
              if(bson_iterator_next(subit)!=BSON_EOO){
                  bson sub_Object[1];
                  bson_iterator_subobject_init(subit, sub_Object,1);
                  //bson_print(sub_Object);
  
                  //comment out the following bson_find could show the expected result
                  if(bson_find(subit, sub_Object, "name"))
                      printf("\tName : %s\n", bson_iterator_string(subit));
                  if(bson_find(subit, sub_Object, "telephone"))
                      printf("\tTelephone: %s\n", bson_iterator_string(subit));
  
                  bson_destroy(sub_Object);
              }
          }
     }
  
  }
  </code></pre>
  
  <p>Output</p>
  
  <blockquote>
    <p>District: HK<br>
       Name: Person A<br>
       Telephone: 1111-1111</p>
  </blockquote>
  
  <p>Any one know why Person B record disappear??</p>
  
  <p>I have test if DO NOT use bson_find inside the second while loop, it could able to print out all the element by bson_print!!</p>
  
  <p>Is there a bug on mongodb ?? Or my code is wrong?</p>
  
  <p>Thank you very much!!!</p>