title: Flatten a nested json object
body: <p>I'm looking for a method that will flatten a "json" hash into a flattened hash but keep the path information in the flattened keys.
  For example:</p>
  
  <pre><code>h = {"a" =&gt; "foo", "b" =&gt; [{"c" =&gt; "bar", "d" =&gt; ["baz"]}]}
  </code></pre>
  
  <p>flatten(h) should return:</p>
  
  <pre><code>{"a" =&gt; "foo", "b_0_c" =&gt; "bar", "b_0_d_0" =&gt; "baz"}
  </code></pre>