title: error using yaml-cpp to get integer nested in key hierarchy
body: <h1>Initial Question</h1>
  
  <p>I have a config.yaml that has structure similar to</p>
  
  <pre><code>some_other_key: 34
  
  a:
    b:
      c:
        d: 3
  </code></pre>
  
  <p>I thought I could do</p>
  
  <pre><code>YAML::Node config = YAML::LoadFile(config_filename.c_str());
  int x  = config["a"]["b"]["c"]["d"].as&lt;int&gt;();
  </code></pre>
  
  <p>but I get </p>
  
  <pre><code>terminate called after throwing an instance of
  'YAML::TypedBadConversion&lt;int&gt;' 
  what():  bad conversion
  </code></pre>
  
  <p>How do I descend through my config.yaml to extract a value like this? I also get that same exception if I mistype one of the keys in the path, so I can't tell from the error if I am accidentally working with a null node or if there is a problem converting a valid node's value to int</p>
  
  <h1>Follow up After First Replies</h1>
  
  <p>Thank you for replying! Maybe it is an issue with what is in the config.yaml? Here is a small example to reproduce,</p>
  
  <h2> yaml file: config2.yaml </h2>
  
  <pre><code>daq_writer:
    num: 3
    num_per_host: 3
    hosts:
      - local
    datasets:
      small:
        chunksize: 600
  </code></pre>
  
  <h2>Python can read it:</h2>
  
  <p>Incidentally, I am on linux on rhel7, but from a python 3.6 environment, everything looks good:</p>
  
  <pre><code>$ python -c "import yaml; print(yaml.load(open('config2.yaml','r')))"
  {'daq_writer': {'num_per_host': 3, 'num': 3, 'datasets': {'small': {'chunksize': 600}}, 'hosts': ['local']}}
  </code></pre>
  
  <h2>C++ yaml-cpp code</h2>
  
  <p>The file yamlex.cpp:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;iostream&gt;
  #include "yaml-cpp/yaml.h"
  
  int main() {
    YAML::Node config = YAML::LoadFile("config2.yaml");
    int small_chunksize = config["daq_writer"]["datasets"]["smal"]["chunksize"].as&lt;int&gt;();
  }
  </code></pre>
  
  <p>When I compile and run this, I get:</p>
  
  <pre><code>(lc2) psanagpu101: ~/rel/lc2-hdf5-110 $ c++ --std=c++11 -Iinclude -Llib -lyaml-cpp yamlex.cpp
  (lc2) psanagpu101: ~/rel/lc2-hdf5-110 $ LD_LIBRARY_PATH=lib ./a.out
  terminate called after throwing an instance of 'YAML::TypedBadConversion&lt;int&gt;'
    what():  bad conversion
  Aborted (core dumped)
  (lc2) psanagpu101: ~/rel/lc2-hdf5-110 $ gcc --version
  gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
  </code></pre>
  
  <p>I have been able to read top level keys, like the <code>some_other_key</code> that I referenced above, but I got an error when I went after this nested key. Good to know that syntax works!</p>