bson_append_start/finish_object should be outside the loop