title: yaml-cpp Easiest way to iterate through a map with undefined values
body: <p>I'd like to obtain every node in a map without knowing the keys.</p>
  
  <p>My YAML looks like this:</p>
  
  <pre><code>characterType :
   type1 :
    attribute1 : something
    attribute2 : something
   type2 :
    attribute1 : something
    attribute2 : something
  </code></pre>
  
  <p>I don't know how many "type"s will be declared or what the name of those keys will be. That's why I'm trying to iterate through the map.</p>
  
  <pre><code>struct CharacterType{
    std::string attribute1;
    std::string attribute2;
  };
  
  namespace YAML{
    template&lt;&gt;
    struct convert&lt;CharacterType&gt;{
      static bool decode(const Node&amp; node, CharacterType&amp; cType){ 
         cType.attribute1 = node["attribute1"].as&lt;std::string&gt;();
         cType.attribute2 = node["attribute2"].as&lt;std::string&gt;();
         return true;
      }
    };
  }
  
  ---------------------
  std::vector&lt;CharacterType&gt; cTypeList;
  
  for(YAML::const_iterator it=node["characterType"].begin(); it != node["characterType"].end(); ++it){
     cTypeList.push_back(it-&gt;as&lt;CharacterType&gt;());
  }
  </code></pre>
  
  <p>The previous code doesn't give any trouble when compiling but then at execution time I get this error:
  terminate called after throwing an instance of <code>YAML::TypedBadConversion&lt;CharacterType&gt;</code></p>
  
  <p>I've also tried using a subindex instead of the iterator, getting the same error.</p>
  
  <p>I'm sure I'm doing something wrong, I just can't see it.</p>