title: How can I retrieve nested values from typesafe config with java?
body: <p>The examples in typesafe config require you to know a path to specify literally, e.g.:</p>
  
  <pre><code>config1.getString("complex-app.something")
  </code></pre>
  
  <p>I need to be able to parse a config file with free-form labels in places. How can I handle that.</p>
  
  <p>Say that I have HOCON like:</p>
  
  <pre><code>root : {
    a : { x: 1, y: 2 },
    b : { x: 2, z: 3 }
  }
  </code></pre>
  
  <p>Without knowing what keys are in the file, how can I find out that there are keys 'a' and 'b' and that the value of the object with key 'a' has keys 'x' and 'y' and for 'b' there are keys 'x' and 'z'?</p>
  
  <p>Here is one way to not do it:</p>
  
  <pre><code>Config config = ConfigFactory.load("configula");
  Config root = config.getObject("root").toConfig();
  for (Entry&lt;String, ConfigValue&gt; e: root.entrySet()) {
      // The key is a.x, a.y etc. ??!?
      // The value is not a map-like thing
  }
  </code></pre>
  
  <p>With the keys of the entry set being a path, I have to parse the path to find what the keys were, which is pretty close to making it easier to simply parse a text file with StringTokenizer or the like.</p>
  
  <p>What is the the config way of parsing nested objects? For example, with groovy and ConfigSlurper a similar structure:</p>
  
  <pre><code>root {
    a {
      x = 1
      y = 2
    }
    b {
      x = 2
      z = 3
    }
  }
  </code></pre>
  
  <p>would be parsed like this:</p>
  
  <pre><code>cfg = new ConfigSlurper().parse(new File('configula.config'))
  cfg.root.each { k, r -&gt;
    r.each { kk, v -&gt;
      println "${k}, ${kk} -&gt; ${v}"
    }
  }
  </code></pre>
  
  <p>every combination of things I've tried ends up with the value being a ConfigValue. Is there a way to get a tree of keys that map to objects that themselves contain keys that map to objects?</p>